问题描述
- axis访问sap的webserv多返回值问题
-
sap的 wsdl文件部分:
/xsd:sequence
/xsd:complexType
/xsd:element/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema
/wsdl:types我的java代码:
public static void main(String args[]) {
String wsdlURISap = """";
String namespaceURI = """";
String operationName = """";String serviceLocalPart = """"; //
String portName = """"; //try{ wsdlURISap = ""http://192.168.108.106:8001/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zmminterface/300/mmservices/binding?sap-client=300?wsdl""; namespaceURI = ""urn:sap-com:document:sap:soap:functions:mc-style"";// operationName = ""Zmminterface"";// serviceLocalPart = ""mmservices"" ;// portName = ""binding"" ;// //5个参数测试值 String Iheads =""1""; String Iitems=""2""; String Intid = ""3""; String Iselec = ""4""; String Paras =""5""; Object[] arg0 = new Object[] { Iheads IitemsIntid Iselec Paras }; Parser wsdlParser = new Parser(); //这里用户名密码设置有用 ,比如不设置会把url无效 wsdlParser.setUsername(""sapuser""); wsdlParser.setPassword(""123321""); wsdlParser.run(wsdlURISap); // 名命空间,服务名 QName qName = new QName(namespaceURI serviceLocalPart); Service clientService = new Service(wsdlParser qName); javax.xml.rpc.Call call = clientService.createCall( QName.valueOf(portName) QName.valueOf(operationName)); // http 方式认证用户名和密码 ((org.apache.axis.client.Call) call).getMessageContext().setUsername(""sapuser""); // httpbase认证用户名 ((org.apache.axis.client.Call) call).getMessageContext().setPassword(""123321""); ((org.apache.axis.client.Call) call).setTimeout(new Integer(30 * 1000)); //调用sap String result = (String) call.invoke(arg0); System.out.println(result); } catch(Exception e ){ System.out.println(""clientSAP方法返回值 *****""+e.toString() ); }} ========================================== 异常: [ERROR] Exception:
org.xml.sax.SAXException: Deserializing parameter 'Eheads': could not find deserializer for type {urn:sap-com:document:sap:rfc:functions}string
at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:277)
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:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.infor.webService.client.SapWebServiceClinet.main(SapWebServiceClinet.java:60)==========================问题像是:三个字符型的返回值, 我要怎么 定义接收 ?
解决方案
wsdl文件重复发一遍:
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema
/wsdl:types
解决方案三:
如果用axis2的RPC 方式访问会报: *****org.apache.axis2.AxisFault: First Element must contain the local name Envelope but found definitions