Error: "First Element must contain the local name, Envelope, but found definitions";
Cause: EndpointReference end = new EndpointReference (URL), URL error;
Source:
1 ImportOrg.apache.axiom.om.OMAbstractFactory; 2 ImportOrg.apache.axiom.om.OMElement; 3 ImportOrg.apache.axiom.om.OMFactory; 4 ImportOrg.apache.axiom.om.OMNamespace; 5 ImportOrg.apache.axis2.AxisFault; 6 ImportOrg.apache.axis2.addressing.EndpointReference; 7 ImportOrg.apache.axis2.client.Options; 8 ImportOrg.apache.axis2.client.ServiceClient; 9 public classTest {One public static void main (string[] args) throwsAxisfault {omelement element = Test ("22", "444", "123"); 13System.out.println (Element.gettext ()); 14}15 private static Omelement test (string Contractno, String contractname, String Auditmoney) throwsAxisfault {Omfactory factory =Omabstractfactory.getomfactory () omnamespace ns1 = Factory.createomnamespace ("http://wwww.test.com/ updatecontractdeductmoneysrv/"," upd "), Omnamespace ns = Factory.createomnamespace ("", ""); 20Omelement result;21 ServiceClient sc = newServiceClient (); Options opts =Sc.getoptions (); //String URL = "HTTP://LOCALHOST:8989/TEST/SERVICES/UPDATECONTRACTAUDITMONEYSRV?WSDL"; Error: String url = "HTTP://LOCALHOST:8989/TEST/SERVICES/UPDATECONTRACTDEDUCTMONEYSRV"; Correct endpointreference end = newEndpointReference (URL); Omelement method = Factory.createomelement ("Updatemoneycollection", NS); omelement param = factory.createomelement ("Contractno", NS); 28Param.settext (CONTRACTNO); 29Method.addchild (param); param = factory.createomelement ("Contractname", NS); 31Param.settext (contractname); 32Method.addchild (param); param = factory.createomelement ("Auditmoney", NS); 34Param.settext (Auditmoney); 35Method.addchild (param); PNS param = factory.createomelement ("Items", NS); Omelement newoperation = Factory.createomelement ("NewOperation1", ns1); 39Param.addchild (newoperation); Omelement Contractlineno = Factory.createomelement ("Contractlineno", NS); Contractlineno.settext ("1"); 42Newoperation.addchild (Contractlineno); Omelement Lineauditmoney = Factory.createomelement ("LineAuditMoney", NS), Lineauditmoney.settext ("at" ), and Newoperation.addchild (Lineauditmoney); Method.addchild (param); method.build (); System.out.println ("method===" + method.tostring ()); {Wuyi sc.settargetepr (end), and the result = sc.sendreceive (method); "+" Catch (Axisfault axisfault) {5 4 result = Factory.createomelement ("Return" , NS), omelement flag = factory.createomelement ("flag" , NS); 56 Flag.settext (ERROR), integer.tostring result.addchild (flag), omelement message = Factory.createomelement ("message" , NS); Message.settext (Axisfault.getreason ()); Result.addchild (message); SYSTEM.OUT.PRINTLN ("result =" + result); }63 System.out.println ("result =" + result); result;65 }66}
WebService Client invocation and exception information first Element must contain the local name, Envelope, but found definitions