org.xml.sax.SAXException:在Java中使用Axis的{http://www.w3.org/2001/XMLSchema}anyType没有反序列化器

时间:2012-07-06 20:21:27

标签: java axis wsdl2java

我正在使用从WSDL创建的Java源包进行soap调用。

在插入必要的详细信息后,应用程序进行调用并收到错误;

代码:

public static String getRioInformation(String msisdn, String endpoint_address) {
     String rio_response="";
   try {
       System.out.println("here  :");
       FwiEsbWs4USSDLocator locator=new FwiEsbWs4USSDLocator();
       locator.setMaintainSession(true);

       locator.setFwiEsbWs4USSDEndPointEndpointAddress(endpoint_address);

       FwiEsbWs4USSDSoapBindingStub temp;

       FwiEsbWs4USSD fwi;
       FwiEsbWs4USSDPortType port;
       GetRioInformationsRequest rio=new GetRioInformationsRequest();
       RioSearchRequest search=new RioSearchRequest();
       search.setMsisdn(msisdn);

       DefaultContext def_context = new DefaultContext();
       DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       def_context.setEffectiveDatetime(Calendar.getInstance());

       def_context.setSystem(MappingSystem.USSD);
       search.setContext(def_context);
       rio.setRioSearchRequest(search);

       FwiEsbWs4USSD cg= null;

       //QName q = new QName("http://service.digicel.fr/", "GetRioInformationsRequest");
       int responseCode=0;
       try {
            //cg=locator.;

           port =  locator.getFwiEsbWs4USSDEndPoint();


           DefaultResponse def=new DefaultResponse();



           def= port.getRioInformations(rio);

           ContextEnrichment context = def.getEnrichment();
           RioInformation[] rio_info =context.getRioInformation();
           rio_response = rio_info[0].getRIO();
       } catch (ServiceException ex) {
           System.out.println("ex 1 :"+ex);
       } 


  } catch (Exception e) {
    System.err.println("SOAP Call Error: "+e.toString());
    e.printStackTrace();
  }
   return rio_response;
}

错误:

SOAP Call Error: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode: 
faultString: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
faultActor: 
faultNode: 
faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
    at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:314)
    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:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.client.Call.invoke(Call.java:2448)
    at org.apache.axis.client.Call.invoke(Call.java:2347)
    at org.apache.axis.client.Call.invoke(Call.java:1804)
    at fr.digicel.service.DigicelFwiEsbWs4USSDSoapBindingStub.getRioInformations(DigicelFwiEsbWs4USSDSoapBindingStub.java:2333)
    at com.digicel.mynumber.SOAPInteractions.getRioInformation(SOAPInteractions.java:107)
    at com.digicel.mynumber.Main.<init>(Main.java:97)
    at com.digicel.mynumber.Main.main(Main.java:253)
org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
    at org.apache.axis.client.Call.invoke(Call.java:2451)
    at org.apache.axis.client.Call.invoke(Call.java:2347)
    at org.apache.axis.client.Call.invoke(Call.java:1804)
    at fr.digicel.service.DigicelFwiEsbWs4USSDSoapBindingStub.getRioInformations(DigicelFwiEsbWs4USSDSoapBindingStub.java:2333)
    at com.digicel.mynumber.SOAPInteractions.getRioInformation(SOAPInteractions.java:107)
    at com.digicel.mynumber.Main.<init>(Main.java:97)
    at com.digicel.mynumber.Main.main(Main.java:253)
Caused by: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
        at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:314)
        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:236)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
        at org.apache.axis.client.Call.invoke(Call.java:2448)
        ... 6 more

错误发生在“def = port.getRioInformations(rio);”行,解决错误需要什么? 什么样的反序列化代码需要解决此问题?

1 个答案:

答案 0 :(得分:2)

在经过几天的努力和同事的帮助后,我已经遇到了同样的问题,我已经得出结论。在你的responceType类中(你想从xml响应对象中解析)在静态块中。 elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "anyType"));

将此QName更改为

elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));