我尝试了很多次连接到Api wsdl,但我不知道为什么这段代码不起作用。
来自文档的示例查询:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/"
xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem: GetMigrationData201901>
<tem:AuthToken>user key</tem:AuthToken>
<tem:NIP>
<arr:string>5840778201</arr:string>
</tem:NIP>
</tem: GetMigrationData201901>
</soapenv:Body>
</soapenv:Envelope>
我的代码:
$options = array('trace'=>1,
'exceptions'=> 1,
'style'=> SOAP_DOCUMENT,
'use'=> SOAP_LITERAL
);
$soapClient = new SoapClient('https://datastoretest.ceidg.gov.pl/CEIDG.DataStore/services/DataStoreProvider201901.svc?wsdl',$options);
try {
$versionResponse = $soapClient->GetMigrationData201901(array("tem:AuthToken"=>"abcde12345abcde12345","tem:NIP"=>['arr:string'=>'8252052153']));
} catch (\Exception $e){
throw new \Exception("Soup request failed! Response: ".$soapClient->__getLastResponse());
}
echo "VERSION RESPONSE: <pre>";
print_r($versionResponse);
echo "</pre><br><br><pre>";
echo 'SOAP CLIENT PRINT: <pre>';
print_r($soapClient);
echo "</pre><br>LAST REQUEST: <pre>";
print_r($soapClient->__getLastRequest());
echo "</pre>";
我的结果:
request:
[__last_response_headers] => HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
Set-Cookie: ASP.NET_SessionId=scsd2k14jytmlrb14l4mnmof; path=/; HttpOnly
X-Powered-By: ASP.NET
Date: Sun, 28 Apr 2019 15:22:49 GMT
Content-Length: 272
response - empty