如何将复杂类型从 PHP SoapClient 发送到 ASP.NET SOAP 服务器?
您好,我在将数组、结构体和结构体数组从 PHP 发送到 ASP.NET SOAP 服务器时遇到问题...
有人对此有解决方案吗?我已经用谷歌搜索了好几天,任何解决方案都对我有用。也许我忘记了一些事情...
我的代码有一些示例:
$client = new SoapClient($options);
$pCriteria = new stdClass();
$pCriteria->type=1;
$pCriteria->capacity=4;
//Test 1 (fail):
$resp = $client->GetRooms(array("pCriteria"=>$pCriteria));
//Test 2 (fail):
$resp = $client->GetRooms(array("pCriteria"=>new SoapVar($pCriteria, SOAP_ENC_OBJECT, "TCriteria", "http://www.w3.org/2001/XMLSchema")));
print_r($resp);
我也不知道如何编写需要 TCriteria 数组(TCriteria[],TCriteria_Array 类型)的函数...我已经尝试发送原始数据数组,具有 SOAP_ENC_ARRAY 编码和 TCriteria_Array 类型的 SoapVar,...但它不起作用(SOAP 服务器变得不可用,需要重新启动)。
我也尝试过为复杂类型创建类,而不是 stdClass,但不起作用。
我不知道问题出在哪里。服务器管理员无法帮助我,我还没有通过互联网找到任何解决方案。我有点绝望了呵呵。
你能帮我吗?您能否提供三种情况(简单数据数组、结构体数组和结构体)的代码示例?谢谢!
Hello I'm having problems sending arrays, structs and arrays of structs from PHP to an ASP.NET SOAP server...
Anyone have a sollution for this? I've googled for days and any sollution worked for me. Perphaps I'm forgetting something...
There are examples of my code:
$client = new SoapClient($options);
$pCriteria = new stdClass();
$pCriteria->type=1;
$pCriteria->capacity=4;
//Test 1 (fail):
$resp = $client->GetRooms(array("pCriteria"=>$pCriteria));
//Test 2 (fail):
$resp = $client->GetRooms(array("pCriteria"=>new SoapVar($pCriteria, SOAP_ENC_OBJECT, "TCriteria", "http://www.w3.org/2001/XMLSchema")));
print_r($resp);
I don't know how to code functions that require an array of TCriteria (TCriteria[], TCriteria_Array type) either... i've tried sending the raw array, a SoapVar with SOAP_ENC_ARRAY encoding and TCriteria_Array type, ... but it does not work (the SOAP server becomes unavaiable and needs to be restarted).
I've tried creating classes for the complex types too, instead of stdClass, but not working.
I don't know where's the problem. The server admins cannot help me and I haven't found any sollution over internet. I'm a bit desperate hehe.
Can you help me please? Can you provide samples of code with the three cases (array of simple data, array of struct and struct) ? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到过类似的情况,PHP Soap 客户端使用 WSDL 2.0 与 .NET Soap 服务器进行通信。我发现了一件事:将信息传递到服务器时,必须将变量显式定义为 SoapVar 对象。因此,在上面的示例中,将其更改为:
传递数组类似,本质上传递 SoapVars 数组:
此外,您可以使用 SoapClient 的多个内置函数来获取有关可能错误的一些附加反馈。
如果您可以获得预期 WSDL 格式的副本,则可以使用上述命令的响应来确定出了什么问题。通常您可以从传递给 SoapClient 的 URL 访问它。例如,如果 WSDL 服务 URL 为 http://example.com/webservices/wvrgroupservice .asmx?WSDL,输入 http://example.com/webservices/wvrgroupservice.asmx< /a> 查看该服务器的功能和预期的 XML。
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:
Passing an array is similar, essentialy you pass an array of SoapVars:
Also, you can use several built-in functions of the SoapClient to get some additional feedback on possible errors.
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.