Wednesday, 8 June 2016

Generate Service Endpoint for SOAP webservices using Apache CXF

This blog is to explain on how to generate the Web service client interfaces for the SOAP web service using Apache CXF.

1) Generate the WSDL file out of SoapUI tool or through any web browser by giving the WSDL URL. Save the generated the file as PurchaseOrder.wsdl

2) Download the CXF2.7.11 from the apache website into the local drive. Then, refer that path in to Eclipse->Windows->Preferences->Webservices->CXF. Please refer the screenshot below.




3) Create a Dynamic web project named WS-SEI with default values.

4) Add the CXF library files from the downloaded one to the above project, so that wsdl2java program of CXF will run without any issues.
5) Move the wsdl file (PurchaseOrder.wsdl) into the Webcontent of the above project
6) Select the above project->File->New->Other->Web Service Client.
7) Select the WSDL file from the project for which you want to create the web service client files.
Change the Web Service Runtime to Apache CXF 2.x (Default value is Apache Axis)



8) Click Next and then select the source directory of the project where you want to create the client files.
9) Enter the Package name to bundle the client files (in this case, com.cfa.webservice.client.purchaseorder)
10) Select the check box “Specify WSDL Namespace to Package Name Mappings”
11) Select the check boxes that are selected in the attached screen below and then click Next


The new window will open. Just click Finish to generate the client files.


This will generate the list of Java classes with the sample date to invoke the web service. The program can be executed as a Core Java application or can be integrated with the web application to invoke the SOAP web service.

No comments:

Post a Comment