[英]php soap Error :Object reference not set to an instance of an
I am trying to use this webservice 我正在尝试使用此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>
below is my class definition 下面是我的班级定义
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);
}
call and create class object $abnlookup = new abnlookup($abn_guid); 调用并创建类对象$ abnlookup = new abnlookup($ abn_guid); $result = $abnlookup->searchByName($name);
$ result = $ abnlookup-> searchByName($ name);
and recieve this msg Server was unable to process request. 并收到此msg服务器无法处理请求。 ---> Object reference not set to an instance of an object.second
--->对象引用未设置为object.second的实例
The $params structure you are passing to ABRSearchByName is not correct. 传递给ABRSearchByName的$ params结构不正确。 According to WSDL this structure has two fields (as shown by __getTypes()):
根据WSDL,这个结构有两个字段(如__getTypes()所示):
struct ABRSearchByName {
ExternalRequestNameSearch externalNameSearch;
string authenticationGuid;
}
Create your $params with these two fields and the problem should be resolved. 使用这两个字段创建$ params,应该解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.