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