Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What methods exist to auto-generate java client stubs from WSDL files?

Tags:

java

wsdl

axis2

I'm new to web-services and have read up some info about XML,SOAP,and WSDL. It's very interesting! I'm working on an existing project that has a web-service and client. However the client the 'higher ups' aren't pleased with the client application. It's too complex, they would like a more user friendly and simpler app that can be easily expanded.

The project uses Apache Axis2. I've found the WSDL files and would like to build a client based on that. However I don't want to use Axis2 for the above reasons( their opinion). I wonder how a simpler a client I can make given that I have to work with already existing code(wsdl files)Does anyone know any other methods I can use to auto generate client stubs based on the existing WSDL files? I've heard of wsimport, this should still work even if the wsdl files were created using Axis2?

Any help or tips are greatly appreciated.

like image 899
ghostlines Avatar asked Jul 23 '10 09:07

ghostlines


People also ask

How do you generate the client code from a WSDL?

Generate the client code as follows: In the Project Explorer, right-click your client project's WSDL file, and then select WebLogic Web Services > Generate Web Service Client from the drop-down menu, as Figure 1 shows. This will open the New Web Service Client dialog that Figure 2 shows.

How is WSDL file generated in Java?

Create a WSDL descriptor from Java code Select the desired class name in the editor. In the main menu, go to Tools | XML WebServices and WSDL | Generate WSDL From Java Code. In the Generate WSDL From Java dialog that opens, specify the following: The name and URL address of the Web service.


2 Answers

Well, we used xfire, but not the wsdl-centric approach: wsdl was created on the fly from the exposed remote interfaces. Client had the same interfaces which were mapped to the generated wsdl automagically.

AFAICS xfire evolved into CXF, and the CXF home page tells me this:

CXF supports both contract first development with WSDL and code first development starting from Java. For REST, CXF also supports a JAX-RS (TCK compliant) frontend.

As I understood you'll need wsdl2java tool to generate client-side stubs from existing WSDL file if you choose to base on wsdl. If both peers run java, then java-centric approach is applicable and quite more transparent (as service interfaces/POJOs may be shared across client/server with transport generated in runtime w/o any stub/proxy generation steps).

like image 154
Anton Kraievyi Avatar answered Sep 20 '22 07:09

Anton Kraievyi


See Step1: Generate Skeleton Code:

To generate the skeleton and required classes, you can use the WSDL2Java tool provided in Axis2. This tool is located in the bin directory of the distribution and can be executed using the provided scripts (.bat or .sh).

$ wsdl2java.sh -uri ../samples/wsdl/Axis2SampleDocLit.wsdl -ss -sd -d xmlbeans 
    -o ../samples -p org.apache.axis2.userguide
like image 26
miku Avatar answered Sep 19 '22 07:09

miku