簡體   English   中英

php soap錯誤:對象引用未設置為的實例

[英]php soap Error :Object reference not set to an instance of an

我正在嘗試使用此Web服務

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ABRSearchByName xmlns="http://abr.business.gov.au/ABRXMLSearch/">
      <externalNameSearch>
        <authenticationGUID>string</authenticationGUID>
        <name>string</name>
        <filters>
          <nameType>
            <tradingName>string</tradingName>
            <legalName>string</legalName>
          </nameType>
          <postcode>string</postcode>
          <stateCode>
            <QLD>string</QLD>
            <NT>string</NT>
            <SA>string</SA>
            <WA>string</WA>
            <VIC>string</VIC>
            <ACT>string</ACT>
            <TAS>string</TAS>
            <NSW>string</NSW>
          </stateCode>
        </filters>
      </externalNameSearch>
      <authenticationGuid>string</authenticationGuid>
    </ABRSearchByName>
  </soap:Body>
</soap:Envelope>

下面是我的班級定義

class abnlookup extends SoapClient{

    private $guid = "00000000"; 

    public function __construct($guid)
    {
        $this->guid = $guid;
        $params = array(
            'soap_version' => SOAP_1_1,
            'exceptions' => true,
            'trace' => 1,
            'cache_wsdl' => WSDL_CACHE_NONE
        ); 

        parent::__construct('http://abr.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx?WSDL', $params);
    }

        public function searchByName($name){
            $params = new stdClass();
            $params->name= $name;
            $params->nameType= 'Y' ;
            $params->postcode= 'Y';
            $params->stateCode= 'N' ;           
    $params->authenticationGuid         = $this->guid;
                return $this->ABRSearchByName($params);
}  

調用並創建類對象$ abnlookup = new abnlookup($ abn_guid); $ result = $ abnlookup-> searchByName($ name);

並收到此msg服務器無法處理請求。 --->對象引用未設置為object.second的實例

傳遞給ABRSearchByName的$ params結構不正確。 根據WSDL,這個結構有兩個字段(如__getTypes()所示):

struct ABRSearchByName {
 ExternalRequestNameSearch externalNameSearch;
 string authenticationGuid;
}

使用這兩個字段創建$ params,應該解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM