[英]Problems in using PHP Soap Client
我可以通過以下配置訪問此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>
<Executar xmlns="http://localhost/I9ProWebService">
<Servico>string</Servico>
<conteudoXML>string</conteudoXML>
</Executar>
</soap:Body>
</soap:Envelope>
所以我嘗試了這個:
$client = new soapclient('https://domain/webservice/I9ProWebService.asmx?WSDL');
printf($client->Executar("ListarTomador","<i9proerp><listar_tomador id_pessoa_corretor =\"205\" /></i9proerp>"));
它顯示此錯誤:
System.Web.Services.Protocols.SoapException:服務器無法處理請求。 ---> System.NullReferenceException:對象引用未設置為對象的實例。 在I9ProWebService.Executar(String Servico,String conteudoXML)-內部異常堆棧跟蹤的結尾-
您是否嘗試過使用htmlentities或類似方法編碼要發送的XML作為第二個參數? 這可能導致SOAP客戶端發送的XML出現問題。
編輯 :為了查看PHP SOAP客戶端正在發送什么XML和它返回什么,可以使用$client->__getLastRequest()
和$client->__getLastResponse()
並將結果與soapUI調用進行比較。
我找到了解決問題的辦法。
$client = new SoapClient("http://domain/webservice/I9ProWebService.asmx?WSDL", array("features" => SOAP_SINGLE_ELEMENT_ARRAYS, "encoding" => "utf-8","trace"=> TRUE));
$strVariavel = "<ns1:conteudoXML><i9proerp><listar_tomador id_pessoa =\"999\"/></i9proerp></ns1:conteudoXML>";
$soapvar = new SoapVar($strVariavel, 147);
$xml = $client->ExecutarXML(array('Servico'=>'ListarTomador','conteudoXML'=>$soapvar));
print_r($xml);
和voilá
問題是它返回並成為對象,而不是我所期望的XML。
它返回:
stdClass Object
(
[ExecutarXMLResult] => stdClass Object
(
[any] => <i9proerp xmlns=""><listatomador id_pessoa="5251" nm_pessoa="nome1" nr_cnpj_cpf="132132121332"/><listatomador id_pessoa="939" nm_pessoa="nome2" nr_cnpj_cpf="3213213123213"/></i4proerp>
)
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.