How to generate your JAXWS service from a WSDL using wsimport

If you have a WSDL file and want to generate a JAXWS service/client, this post will help you. You can use the wsimport tool which is shipped with JDK (1.5 onwards).

Install JDK on your machine and just try “wsimport” command in a shell. It will show you the help.

Here are the options it provides.

Usage: wsimport [options] <WSDL_URI>

where [options] include:
-b <path> specify jaxws/jaxb binding files or additional schemas (Each <path> must have its own -b)
-B<jaxbOption> Pass this option to JAXB schema compiler
-catalog <file> specify catalog file to resolve external entity references supports TR9401, XCatalog, and OASIS XML Catalog format.
-d <directory> specify where to place generated output files
-extension allow vendor extensions – functionality not specified by the specification.  Use of extensions may result in applications that are not portable or may not interoperate with other implementations
-help display help
-httpproxy:<host>:<port> specify a HTTP proxy server (port defaults to 8080)
-keep keep generated files
-p <pkg> specifies the target package
-quiet suppress wsimport output
-s <directory> specify where to place generated source files
-target <version> generate code as per the given JAXWS specification version. version 2.0 will generate compliant code for JAXWS 2.0 spec.
-verbose output messages about what the compiler is doing
-version print version information
-wsdllocation <location> @WebServiceClient.wsdlLocation value

Examples:
wsimport stock.wsdl -b stock.xml -b stock.xjb
wsimport -d generated http://example.org/stock?wsdl

Just as shown in the above 2nd example, generate .java files as well if you want to create a service out of this. Among these generate classes, there is a generated interface of you web service. Just implement that interface and that is your web service class. Then add the @WebService annotation at the top as follows.

@WebService(
serviceName = “ComplexService”,
targetNamespace = “http://complex.axis2.apache.org&#8221;,
portName = “ComplexServiceHttpSoap11Endpoint”,
wsdlLocation = “ComplexService.wsdl”,
endpointInterface = “org.apache.axis2.complex.ComplexServicePortType”)

These details should be according to your WSDL’s definitions.

Advertisement

About isurues
Age : 24 Date of Birth : 05.11.1984 Country : Sri Lanka

3 Responses to How to generate your JAXWS service from a WSDL using wsimport

  1. Polprav says:

    Hello from Russia!
    Can I quote a post in your blog with the link to you?

  2. Conor says:

    “interface of you web service” should read “interface of your web service”. Bad grammar winds me up.

  3. duh says:

    @Conor

    That’s a typo error, not a grammar error. u r an a$$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: