Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code generated by wsimport - best practice for packing the code

I have a question regarding generating Java artifacts with wsimport tool (by Maven Jax-WS )

When I generate the Java artifacts from WSDL, I would like to pack the web service project as a WAR file, and its client as a JAR file.

Where to put the generated artifacts and where to put the WSDL? What is the best practice regarding organizing web service projects?

Thank you in advance!

Best regards, Jurica Krizanic

like image 742
Jurica Krizanic Avatar asked Aug 31 '12 18:08

Jurica Krizanic


People also ask

What is wsimport command?

The wsimport command-line tool processes an existing Web Services Description Language (WSDL) file and generates the required artifacts for developing Java™ API for XML-Based Web Services (JAX-WS) web service applications.


2 Answers

The artifacts will be required on both client and server side so pack them in a third jar and set it as a dependency for both. The WSDLs should go to the WEB-INF folder of the war and the wsdlLocation attribute of @WebService and @WebServiceClient should be set to reflect the path to it.

like image 192
zeller Avatar answered Sep 30 '22 02:09

zeller


Packaging options for managed services are defined in JSR 109: Web Services for Java EE, Version 1.3.

For services:

5.4.2 EJB Module Packaging

...the Web services deployment descriptor location within the EJB-JAR file is META-INF/webservices.xml. The wsdl directory is located at META-INF/wsdl.

5.4.3 Web App Module Packaging

...a Web services deployment descriptor is located in a WAR at WEB-INF/webservices.xml and the wsdl directory is located at WEB-INF/wsdl.

For clients:

A client can be any of the following: Java EE application client, web component, EJB component, or another Web service.

The location of the Web services client deployment descriptor in the module is module specific. WSDL files are located relative to the root of the module and are typically located in the wsdl directory that is co-located with the module deployment descriptor or a subdirectory of it.

Note that this spec restricts itself to Java EE clients; it doesn't mean that you can't have an unmanaged client where you provide the WSDL explicitly.

Cross-reference these specifications for more detail:

  • JSR 244 (JAX-WS)
  • JSR 109 (integration with Java EE)
  • JSR 316 (Java EE 6)
like image 24
McDowell Avatar answered Sep 30 '22 01:09

McDowell