WebService Client invocation and exception information first Element must contain the local name, Envelope, but found definitions

Source: Internet
Author: User
Tags addchild

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.