webservice调用偶发报错nested exception原创
5人赞赏了该文章
2,528次浏览
未经作者许可,禁止转载编辑于2022年07月29日 18:56:21
第三方系统调用EAS webservice接口,偶发报错:
nested exception is:org.xml.sax.SAXException:
Deserializing parameter'':could not find deserializer for type{http://schemas.xmlsoap.org/soap/encoding/}string
1.可先尝试修改调用方代码
//调用登陆接口 Service s=new Service(); Call call=(Call)s.createCall(); call.setOperationName("login"); call.setTargetEndpointAddress(" call.setReturnType(new QName("urn:client","WSContext")); call.setReturnClass(WSContext.class); call.setReturnQName(new QName("","loginReturn")); //超时 call.setTimeout(Integer.valueOf(1000*600000*60)); call.setMaintainSession(true); //登陆接口参数 WSContext rs=(WSContext)call.invoke(new Object[]{"am", "", "eas", "bos80demo", "l2", Integer.valueOf(0)}); if(rs. getSessionId() == null){ throw new Exception(“login fail”); } System.out.println(rs.getSessionId()); //清理 call.clearOperation(); //调用业务接口 call.setOperationName("addTest"); call.setTargetEndpointAddress("http://localhost:8080/ormrpc/services/WStettreeFacade"); call.setReturnType(new QName("urn:lang.java","String")); call.setReturnClass(String.class); call.setReturnQName(new QName("","addTestReturn")); call.setTimeout(Integer.valueOf(1000*600000*60)); call.setMaintainSession(true); //设置登录返回的session在soap头 "http://login.webservice.bos.kingdee.com"是固定的 SOAPHeaderElement header=new SOAPHeaderElement("http://login.webservice.bos.kingdee.com","SessionId", rs.getSessionId()); call.addHeader(header); //接口参数 String aa=(String)call.invoke(new Object[]{"test1", "test"} );
如上代码所示,可声明出返回类型
call.setReturnType(new QName("urn:lang.java","String")); call.setReturnClass(String.class);
2.若修改之后调用报错:
No parameters specified to the Call object! You must call addParameter() for all parameters if you have called setReturnType().
需要根据报错修改代码
call.addParameter(new QName("jsonRows"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName("jsonParams"),org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.addParameter("jsonResult",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.OUT);
具体的入参出参类型根据第三方调用方的代码自行调整。
则声明为:
推荐阅读