How to send complex types from PHP SoapClient to ASP.NET SOAP server?

会有一股神秘感。 提交于 2019-12-04 20:16:15
Gabe

I had a similar situation with a PHP Soap Client communicating with a .NET Soap Server using WSDL 2.0. Here's one thing I discovered: When passing the information to the server, you must explicitly define the variable as a SoapVar object. So in your example above, change it to:

$pCriteria->type = new SoapVar(1, XSD_INT, 'xsd:int');

Passing an array is similar, essentialy you pass an array of SoapVars:

$pCriteria->type = array(new SoapVar(1, XSD_INT, 'xsd:int'), new SoapVar(2, XSD_INT, 'xsd:int', new SoapVar(3, XSD_INT, 'xsd:int'));`enter code here`

Also, you can use several built-in functions of the SoapClient to get some additional feedback on possible errors.

$client->__getLastRequest() //To display the XML that you sent to the server
$client->__getLastResponse() //to display the XML that is sent in response to your request

If you can get a copy of the expected WSDL format you can use the response from the above commands to determine what is going wrong. Usually you can access this from the URL that you pass to the SoapClient. So, for example, if the WSDL services URL is http://example.com/webservices/wvrgroupservice.asmx?WSDL, enter http://example.com/webservices/wvrgroupservice.asmx to view the functions and expected XML from that server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!