webservice 调用问题

webservice 方法如下 :
public GWDDNSQueryBean GWDDNSQueryInvoke(WebServiceClient wsclient,String ID) {
      try {
             Service service = new Service();
             Call call = (Call) service.createCall(); 
             QName qn = new QName("GWQuery", wsclient.getWebFuncName());
             QName qn1 = new QName("GWQuery", "GWDDNSQueryBean");  
              call.registerTypeMapping(GWDDNSQueryBean.class, qn1, new BeanSerializerFactory(GWDDNSQueryBean.class,
                      qn1), new BeanDeserializerFactory(GWDDNSQueryBean.class, qn1));
              call.setTargetEndpointAddress(new java.net.URL(wsclient.getWebServiceURL()));   
              call.setOperationName(qn);
              call.setOperationStyle(org.apache.axis.constants.Style.RPC);
              call.setOperationUse(org.apache.axis.constants.Use.ENCODED);
              call.addParameter("arg1",org.apache.axis.encoding.XMLTYPE.XSD_STRING, ParameterMode.IN);
              call.setReturnType(qn1, GWDDNSQueryBean.class);
             Object[] parameters = new Object[] {ID};         
             GWDDNSQueryBean resultBean=(GWDDNSQueryBean) call.invoke(parameters);
              return resultBean;
         } catch (Exception e) {
             CAP.trException(e);
             return null;
        }
    }

出现了序列化错误:

org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.

本来返回值call.registerTypeMapping方法已经处理过了,但还是报错

弄了好长时间搞定,去掉了几个地方,将方法换成如下:

public GWDDNSQueryBean GWDDNSQueryInvoke(WebServiceClient wsclient, String ID) {

        try {
            Service service = new Service();
            Call call = (Call) service.createCall();
            QName qn = new QName("GWQuery", wsclient.getWebFuncName());
            call.setTargetEndpointAddress(new java.net.URL(wsclient.getWebServiceURL()));
            call.setOperationName(qn);
            call.setReturnClass(GWDDNSQueryBean.class);
            Object[] parameters = new Object[] { ID };
            GWDDNSQueryBean resultBean = (GWDDNSQueryBean) call.invoke(parameters);
            return resultBean;
        } catch (Exception e) {
            CAP.trException(e);
            return null;
        }

}

 

很郁闷 !!!

  

你可能感兴趣的:(apache,.net,xml,webservice)