webservice 客户端调用及异常信息first element must contain the local name, envelope , but found definitions... -凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
webservice 客户端调用及异常信息first element must contain the local name, envelope , but found definitions...
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
报错:“first element must contain the local name, envelope , but found definitions”;
原因:endpointreference end = new endpointreference(url) ,url错误;
源代码:
1 import org.apache.axiom.om.omabstractfactory;2 import org.apache.axiom.om.omelement;3 import org.apache.axiom.om.omfactory;4 import org.apache.axiom.om.omnamespace;5 import org.apache.axis2.axisfault;6 import org.apache.axis2.addressing.endpointreference; 7 import org.apache.axis2.client.options; 8 import org.apache.axis2.client.serviceclient; 9 10 public class test { 11 public static void main(string[] args) throws axisfault { 12 omelement element = test("22","444","123"); 13 system.out.println(element.gettext()); 14 } 15 16 private static omelement test(string contractno, string contractname, string auditmoney) throws axisfault { 17 omfactory factory = omabstractfactory.getomfactory(); 18 omnamespace ns1 = factory.createomnamespace("http://wwww.test.com/updatecontractdeductmoneysrv/", "upd"); 19 omnamespace ns = factory.createomnamespace("", ""); 20 omelement result; 21 serviceclient sc = new serviceclient(); 22 options opts = sc.getoptions(); 23 // string url = "http://localhost:8989/test/services/updatecontractauditmoneysrv?wsdl"; //错误 24 string url = "http://localhost:8989/test/services/updatecontractdeductmoneysrv"; //正确 25 endpointreference end = new endpointreference(url); 26 omelement method = factory.createomelement("updatemoneycollection", ns); 27 omelement param = factory.createomelement("contractno", ns); 28 param.settext(contractno); 29 method.addchild(param); 30 param = factory.createomelement("contractname", ns); 31 param.settext(contractname); 32 method.addchild(param); 33 param = factory.createomelement("auditmoney", ns); 34 param.settext(auditmoney); 35 method.addchild(param); 37 param = factory.createomelement("items", ns); 38 omelement newoperation = factory.createomelement("newoperation1", ns1); 39 param.addchild(newoperation); 40 omelement contractlineno = factory.createomelement("contractlineno", ns); 41 contractlineno.settext("1"); 42 newoperation.addchild(contractlineno); 43 omelement lineauditmoney = factory.createomelement("lineauditmoney", ns); 44 lineauditmoney.settext("23"); 45 newoperation.addchild(lineauditmoney); 46 47 method.addchild(param); 48 method.build(); 49 system.out.println("method===" method.tostring()); 50 try { 51 sc.settargetepr(end); 52 result = sc.sendreceive(method); 53 } catch (axisfault axisfault) { 54 result = factory.createomelement("return", ns); 55 omelement flag = factory.createomelement("flag", ns); 56 // flag.settext(integer.tostring(error)); 57 result.addchild(flag); 58 omelement message = factory.createomelement("message", ns); 59 message.settext(axisfault.getreason()); 60 result.addchild(message); 61 system.out.println("result = " result); 62 } 63 system.out.println("result = " result); 64 return result; 65 } 66 }
转载于:https://www.cnblogs.com/jeffreyluo/p/5236074.html
与50位技术专家面对面20年技术见证,附赠技术全景图总结
以上是凯发k8官方网为你收集整理的webservice 客户端调用及异常信息first element must contain the local name, envelope , but found definitions...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: