The Source for Java Technology Collaboration
User: Password:



Doug Kohlert

Doug Kohlert's Blog

JAX-WS: wsimport tip

Posted by kohlert on November 09, 2005 at 12:59 PM | Comments (3)

The wsimport tool of JAX-WS has added a -p option. This option is used to specify the package that the generated artifacts should be generated into. This option eliminates the need to write a customization to do the same task. For example, two customization files to specify that the package for a WSDL would be similar to the following:
custSchema - customizes the package that generated artifacts from schema use. 
<bindings 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    wsdlLocation="http://localhost:8080/jaxws-external-customize/addnumbers?wsdl"
    xmlns="http://java.sun.com/xml/ns/jaxws">
    <package name="external_customize.client"/>
</binding>

custWsdl - customizes the package that artifacts generated from the WSDL use.
<bindings 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://java.sun.com/xml/ns/jaxb"
    version="1.0">
    <bindings schemaLocation="http://localhost:8080/jaxws-external-customize/addnumbers?xsd=1" node="/xsd:schema">
        <schemaBindings>
            <package name="external_customize.client"/>
        </schemaBindings>
    </bindings>
</bindings>
This would be passed to wsimport using the -b option: For example:
wsimport -b custSchema -b custWsdl http://localhost:8080/jaxws-external-customize/addnumbers?wsdl"

With the new -p option, the same thing can be accomplished with: wsimport -p externa_customize.client http://localhost:8080/jaxws-external-customize/addnumbers?wsdl"

You can see a working sample code using both of these approaches in the external-customize and wsimport_catalog samples included in the nightly build of JAX-WS available here.

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Thanks! This tip was very helpful, as I couldn't find any good info on the bindings tag.

    Posted by: dcalde on November 28, 2005 at 01:23 AM

  • Hey Doug,
    Well this works well if you have to put all your generated artifacts into the same folder. Do you have any clue if wsimport supports packaging the generated artifacts into different packages (but not the default one).

    Regards,
    Sushil

    Posted by: sushil_ojha on July 28, 2006 at 08:42 AM

  • Sushil, the -p option is only intended to solve the most common case of generating the artifacts into one package. You would have to use customizations to map different namespaces to different packages if that is your requirement.

    Posted by: kohlert on July 31, 2006 at 09:47 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds