Java client calls C # 's WebService service

Source: Internet
Author: User

Using the CXF framework here, you can get the relevant jar package from the MAVEN repository using the following coordinates:

1 <Dependency>2   <groupId>Org.apache.cxf</groupId>3   <Artifactid>Apache-cxf</Artifactid>4   <version>3.0.3</version>5   <type>Pom</type>6 </Dependency>

Customizing a Serverproxyer class that provides a way to call WebService

 Packagecom.component;ImportCom.component.util.WebServicePropertyFileUtil;Importorg.apache.cxf.endpoint.Client;Importorg.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;/*** Desc:webservice Service-side proxy class in the local*/ Public classServerproxyer {Private StaticString Wsdlurl; Private Staticclient client; Static{        //Get WSDL addressWebservicepropertyfileutil.init_custom ("WebService"); Wsdlurl= Webservicepropertyfileutil.get ("Wsdlurl"); //Create a client instancejaxwsdynamicclientfactory DCF =jaxwsdynamicclientfactory.newinstance (); Client=dcf.createclient (Wsdlurl); }    /*** Call WebService Service-side method *@paramMethodName Method Name *@paramParameters Parameters *@return     */     Public Staticobject[] Invoke (String methodname,string ... parameters) {object[] res=NULL; Try{res=Client.invoke (methodname,parameters);  for(Object obj:res) {System.out.println (obj); }        } Catch(Exception e) {e.printstacktrace (); }        returnRes; }     Public Static voidMain (string[] args) {Invoke ("Sendmessages", "Haijen", "You have a new TODO:", "Notice of"); }}

Note: There may be a conflict between the third-party jar that the CXF relies on and the jar that your local project already uses, such as Ehcache.jar, which requires handling of the conflicting jar if there is a conflict.

Java client calls C # 's WebService service

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.