今天在使用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"}};
重新調用測試,發現調用成功