博客导读网 |
一个让你随便看看的地方 |
ArrayOf_xsd_string格式在php下的处理推荐9Enjoy |
||
|
使用某服务商的webservice服务,其wsdl里有个这样一个变量: <<wsdl:part name="mobiles" type="impl:ArrayOf_xsd_string" /> 而php里并没有对应的类型。 使用 $mobiles = '18900000000'; $mobiles[0]='18900000000'; 甚至mobiles[0][0]='18900000000'; 都不行,会提示: Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException: No deserializer defined for array type {http://www.w3.org/2001/XMLSchema}string in /www/9enjoy.com/include/hx.php:46 Stack trace: #0 /www/9enjoy.com/include/hx.php(46): SoapClient->__call('sendSM', Array) #1 /www/9enjoy.com/include/hx.php(2): send_mobile('18900000000', '{????????}?????...') #2 {main} thrown in /www/9enjoy.com/include/hx.php on line 46 使用.NET WebService Studio工具测试,将参数填入后,得到request的xml为: <q1:sendSM> <mobiles href="#id1" /> <content xsi:type="xsd:string">test</content> ... </qi:sendSM> <soapenc:Array id="id1" soapenc:arrayType="xsd:string[1]"> <Item>18900000000</Item> </soapenc:Array> 测试多次后发现有两种解决办法: 1.较简单,把ArrayOf_xsd_string这种格式转换为数组格式 <?php $client = new SoapClient("some.wsdl", array('features' => SOAP_USE_XSI_ARRAY_TYPE)); ?> 这时,可使用$mobiles = array('18900000000');来传递$mobiles变量。 这是php5.2.2起增加的功能 引用 - Improved SOAP . Added ability to encode arrays with "SOAP-ENC:Array" type instead of WSDL type. To activate the ability use "feature"=>SOAP_USE_XSI_ARRAY_TYPE option in SoapClient/SoapServer constructors. (Rob, Dmitry) 2.将整个xml文档用doRequest 方法发送出去 public string SoapClient::__doRequest ( string $request , string $location , string $action , int $version [, int $one_way = 0 ] ) Tags - array , soap , php , websevice |
||
| 原文地址:http://item.feedsky.com/~feedsky/9enjoy/~1348731/573838097/1353774/1/item.html |
| © 2010 博客导读网 BlogABC.NET 本站所有内容皆由网友推荐而来,所有博文的版权归原作者所有,如有冒犯,请邮件告知。uncracker#gmail.com |