Nero丶的gravatar头像
Nero丶 2015-04-24 11:40:22

java客户端调用C#的web service为什么抛出反序列化的异常?

Service service = new Service();
        Call call = null;
        try {
            call = (Call) service.createCall();
            call.setTargetEndpointAddress(new URL(
                    "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"));
            call.setOperationName(new QName("http://WebXml.com.cn/",
                    "getWeatherbyCityName"));
            call.addParameter(
                    new QName("http://WebXml.com.cn/", "theCityName"),
                    XMLType.SOAP_VECTOR, ParameterMode.IN);
            call.setReturnType(XMLType.SOAP_VECTOR);
            call.setUseSOAPAction(true);
            call.setSOAPActionURI("http://WebXml.com.cn/getWeatherbyCityName");
            System.out.println(call.invoke(new Object[] { "广州" }));
        } catch (Exception e) {
            e.printStackTrace();
        }

代码调用天气的webservice没有问题,当我用客户提供的c#web service的时候,就会出现异常:SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.大概意思是说什么需要反序列化吧,求大神

AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.
    at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDeserializer.java:145)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:345)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2467)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at main.Main.test2(Main.java:130)
    at main.Main.main(Main.java:33)


    

所有回答列表(1)
柏文JJ的gravatar头像
柏文JJ  LV21 2015年4月24日

把wsdl文件中所有的

<s:sequence>
     <!-- <s:element ref="s:schema" /> -->
     <s:any minOccurs="2" maxOccurs="2" />
 </s:sequence>

修改就可以

顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友