ArrayOf_xsd_string格式在php下的处理

使用某服务商的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 ] )

http://www.9enjoy.com/no-deserializer-defined-for-array-type/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值