CXF Soup WebService Dynamic Client Invoke tool class

Source: Internet
Author: User

After trying a variety of WebService client call methods, still think this method is reliable, this method uses the Apache CXF Framework, the tool class source code is as follows:

Import java.lang.reflect.method;import org.apache.cxf.jaxws.jaxwsproxyfactorybean;public class  wsreq{    private string wsurl;    private class <?> interfaceclz;        pulbic wsreq (String  WSURL,&NBSP;CLASS&LT;?&GT;&NBSP;INTERFACECLZ)  {        this.wsurl  = wsUrl;        this.interfaceClz = interfaceClz;     }        public string invoke (String  methodname, object... params)  throws Exception {         object obj = getwsobject ();         class<?>[] argstypes = new classs[params.length];         for&nbSP; (int i = 0; i < params.length; i ++)  {             if  (params[i] != null)  {                 argsTypes[i] =  Params[i].getclass ();            }         }                 method method = interfaceclz.getmethod (MethodName, argsType);         String result =  (String) method.invoke (obj,  params);         return result;    }             private object getwsobject ()  {    &nBsp;   jaxwsproxyfactorybean factory = new jaxwsproxyfactorybean ();         factory.setaddress (Wsurl);         factory.setserviceclass (INTERFACECLZ);         object obj  =  (Object) factory.create ();        return obj;     }}


This article is from the "Evan" blog, be sure to keep this source http://wenshengzhu.blog.51cto.com/5151285/1851102

CXF Soup WebService Dynamic Client Invoke tool class

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.