Two methods of client invocation of WebService (summary)

Source: Internet
Author: User
Tags wsdl

Recently, I often do interface integration, summed up two ways to call the WebService service using Java, the generation of local client class calls will not say.

The first type:

  Public Staticstring Testoawebservice () {string result= ""; Try{Client C=NewClient (NewURL ("http://10.3.100.100/services/WorkflowService?wsdl")); Object[] Params=NewObject[5]; params[0]=NULL; params[1]=NewInteger (1497276);//Workflow Request IDparams[2]=NewInteger (26626);//NULL node operator IDParams[3]= "Submit";//The process is returned when the parameter is reject, and the process is submitted for submitparams[4]= "Manual Test OA Interface";//Object[] results = C.invoke ("Submitworkflowrequest", params); Result= Results[0].tostring (); } Catch(malformedurlexception e) {System.out.println (e);        E.printstacktrace (); } Catch(Exception e) {System.out.println (e);        E.printstacktrace (); } System.out.println ("Result:" +result); returnresult; }

The second type:

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public static String testOrg2(){        String endpoint= "http://10.3.100.198:8080/ccqc/services/unitSynService?wsdl";          String result = "";        Service service = new Service();          Call call;         try {             call=(Call)service.createCall();               call.setTargetEndpointAddress(endpoint);//远程调用路径               call.setOperationName("untilSynXml");//调用的方法名              //设置返回值类型:               call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//返回值类型:String               result = (String)call.invoke(new Object[0]);//远程调用               System.out.println("result:"+result);        } catch (Exception e) {            e.printStackTrace();        }        return result;    }

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.