今天在使用axis2调用一个Axis1的webservice时出现了一个如下类型的数据
<wsdl:types> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="xxxxxxx"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <complexType name="ArrayOf_xsd_string"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/> </restriction> </complexContent> </complexType> </schema> </wsdl:types>
这个类型的数据在,服务端也就是一个string数组,在客户端写的调用代码自然而然的想到也是映射成一个string数组,调用时出现:
Found character data inside an array element while deserializing
在网上搜索了半天,无果,也没有找到解决办法。关键时刻还是要靠自己。
在使用eclipse里面的web Service Explorer调用时看到请求的SOAP信息如下:
<phone q0:arrayType="xsd:string[1]" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="q0:Array"> <string xsi:type="xsd:string">1592523xxxx</string> </phone>
在使用HttpAnalyzer监控java代码的调时发现传递的这样的信息:
<item0 xmlns="">1592823xxxx</item0> <item0 xmlns="">1338333xxxx</item0>
感觉这个不像是数组,所以我就将java代码中,原先的一维数组变成二维数组试一下
String[] phones = {"1592823xxxx","1338333xxxx"};
String[][] phones = {{"15925232137","1837393xxxx"}};
重新调用测试,发现调用成功