WebServices client implementation of the JAX_WS 2.2 specification (AXIS2,CXF)

Source: Internet
Author: User
Tags wsdl

In order to docking the old version of the interface, tossing for several hours.

Mainly at present my program uses is the Axis2 JAX_RPC Way publishes webservices the service, uses this service the client, to call the old version Jax_ws 2.2 The interface, will report runtime null pointer.

Using CXF, the cxf3.0.3 (current version) Wsdl2java tool was used to generate the client's code:

Wsdl2java ****?wsdl

Wrote a test class to invoke:

 Packagecom.test;Importjava.net.MalformedURLException;ImportJava.net.URL;/*** Created by Wang on 15-1-27.*/ Public classTest { Public Static voidMain (string[] args) {URL wsdllocation=NULL; Try{wsdllocation=NewURL ("* * *"); Nocpacket Nocpacket=NewNocpacket (); Nocpacket.setpayload ("Lasdfsfsdf");Eventforwarderservice Service=NewEventforwarderservice (wsdllocation); Eventforwarderinterface SS=Service.geteventforwarderport (); Feedresult result=ss.send (Nocpacket);        System.out.println (Result.getresultdesc ()); } Catch(malformedurlexception e) {e.printstacktrace (); }    }}

The test is OK and can be called.

But here's a problem. If you use JDK7, it has a JAX_WS 2.2 implementation of the construction method, will not report the problem. However, if you use Jdk6, the CXF generated code, the inherited Services.class less a construction method with feature, jdk6 by default there is only one construct. Here is more ambiguous, look at the JDK source code can see the problem. With jdk6 words, to introduce a package of CXF: Geronimo-jaxws_2.2_spec-1.2.jar. CXF's compression pack comes with.

Then to configure the next package load order, the introduction of the geronimo-jaxws_2.2_spec-1.2 package first load, followed by the JDK. In the case of Eclipse, in the environment path, modify the order. If it is idea, in module, also adjust the order. In this way, under Jdk6 can also be used normally.

CXF is not adopted because the package conflicts with the integration into the AXIS2 environment.

Own use of the Axis2, but with cxf of the client, too pit. Discover Axis2 also has the Wsdl2java tool, decisively uses it to generate the client code, this generated code only two classes, looks very concise:

Wsdl2java-uri  ***?wsdl-o src

Configure the directory to generate the code SRC.

The code is generated, but the calling code has been tortured for a while, according to the code on the Web. So here to share, lest posterity more detours.

 PackageCom.wang;Importjava.rmi.RemoteException;ImportOrg.apache.axis2.AxisFault; Public classTestmain { Public Static voidMain (string[] args) {Try{nocpacket Nocpacket=NewNocpacket (); Nocpacket.setpayload ("1232311"); String urlstring="****"; Eventforwarderservicestub stub=Neweventforwarderservicestub (urlstring); Send Send=NewSend ();                Send.setnocpacket (Nocpacket); Sende Sende=NewSende ();                Sende.setsend (send);; Try{sendresponse response=stub.send (Sende). Getsendresponse (); Feedresult result=Response.getresult ();                System.out.println (Result.getresultdesc ()); } Catch(RemoteException e) {//TODO auto-generated Catch blockE.printstacktrace (); }                            } Catch(Axisfault e) {//TODO auto-generated Catch blockE.printstacktrace (); }    }}

The code on the web, such as calling the Send method I need here, is directly using the Send method. But I have tried many times unsuccessful, must pass through Sende this method object. I do not know if this is Axis2 later modified.

So toss for a long time, finally in the project, only with AXIS2 to complete the server and the client all operations.

WebServices client implementation of the JAX_WS 2.2 specification (AXIS2,CXF)

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.