[英]How to explicitly set parameter type for NuSOAP in PHP
When making a SOAP call with NuSOAP, I'm getting the SOAP fault: 使用NuSOAP进行SOAP调用时,出现SOAP错误:
No deserializer for {http://www.w3.org/2001/XMLSchema}anyType 没有针对{http://www.w3.org/2001/XMLSchema}anyType的反序列化器
The request looks like this: 该请求看起来像这样:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:impl="http://rtw.dncrtelem" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<SOAP-ENV:Body>
<impl:WashNumbers xmlns:impl="http://rtw.dncrtelem">
<TelemarketerId xsi:type="xsd:string">****</TelemarketerId>
<WashOnlyUserId xsi:type="xsd:string">****</WashOnlyUserId>
<TelemarketerPassword xsi:type="xsd:string">****</TelemarketerPassword>
<ClientReferenceId xsi:type="xsd:string">****</ClientReferenceId>
<NumbersToWash xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">
<item xsi:type="xsd:anyType">1234567890</item>
<item xsi:type="xsd:anyType">0987654321</item>
</NumbersToWash>
</impl:WashNumbers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If I paste the request into soapUI and change the type of "item" from "xsd:anyType" to "xsd:string", then it works fine. 如果我将请求粘贴到soapUI中,并将“ item”的类型从“ xsd:anyType”更改为“ xsd:string”,则它可以正常工作。 eg 例如
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:impl="http://rtw.dncrtelem" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<SOAP-ENV:Body>
<impl:WashNumbers xmlns:impl="http://rtw.dncrtelem">
<TelemarketerId xsi:type="xsd:string">****</TelemarketerId>
<WashOnlyUserId xsi:type="xsd:string">****</WashOnlyUserId>
<TelemarketerPassword xsi:type="xsd:string">****</TelemarketerPassword>
<ClientReferenceId xsi:type="xsd:string">****</ClientReferenceId>
<NumbersToWash xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">
<item xsi:type="xsd:string">1234567890</item>
<item xsi:type="xsd:string">0987654321</item>
</NumbersToWash>
</impl:WashNumbers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How can I explicitly set the type for that when constructing my SOAP call? 在构造SOAP调用时,如何显式设置类型? Have searched but can't seem to find the solution. 搜索过,但似乎找不到解决方案。
Here's my PHP code: 这是我的PHP代码:
include_once('lib/nusoap.php');
$client = new nusoap_client('https://www.donotcall.gov.au/dncrtelem/rtw/washing.cfc?wsdl', 'wsdl');
$err = $client->getError();
if($err){
// Error handling here
} else {
$client->setUseCurl(true);
$client->soap_defencoding = 'UTF-8';
$params = array('TelemarketerId'=>'****', 'WashOnlyUserId'=>'****', 'TelemarketerPassword'=>'****', 'ClientReferenceId'=>'****', 'NumbersToWash'=>array('1234567890','0987654321'));
$result = $client->call('WashNumbers', $params);
if ($client->fault) {
// Fault handling here
} else {
$err = $client->getError();
if ($err) {
// Error handling here
} else {
print_r($result);
}
}
}
I was able to resolve this using "soapval", code change as follows: 我能够使用“ soapval”解决此问题,代码更改如下:
$numbers = array('1234567890','0987654321');
$sv1 = array();
foreach ($numbers as $index => $number) {
$sv1[] = new soapval('Number', 'xsd:string', $number);
}
$params = array('TelemarketerId'=>'****', 'WashOnlyUserId'=>'****', 'TelemarketerPassword'=>'****', 'ClientReferenceId'=>'****', 'NumbersToWash'=>$sv1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.