作者sohumi (皮老板)
看板PHP
标题[请益] 使用SoapClient错误但postman测试正常
时间Fri Aug 11 17:02:01 2017
原po使用一简易webservice,只需要丢入一xml资料,假设网址为
https://xxx.xxx.xxx/WebService.asmx?op=setData
使用postman直接将整串
<soap:Envelope
xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
中间略...
</soap:Body>
</soap:Envelope>
参数以raw的方式传出去,可以正常执行.
但若使用SoapClient
$url = "
https://xxx.xxx.xxx/WebService.asmx?WSDL";
$xml = "<soap::Envelope.....中间略....";
$client = new SoapClient($url);
$result = $client->SetData($xml);
或是使用SimpleXMLElement
$xmlr = new SimpleXMLElement($xml);
$parameter = new stdClass();
$parameter->xml = $xmlr->asXML();
$result = $client->SetData($xmlr);
都会回传以下error message
Message: System.Web.Services.Protocols.SoapException:
伺服器无法处理要求。 --->
System.NullReferenceException: 并未将物件参考设定为物件的执行个体
若要将整个xml字串当作raw data送出要怎麽写呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 118.163.24.230
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/PHP/M.1502442128.A.07D.html
1F:→ mirae: google php curl post raw data 08/14 09:55