Categories
Java Web Development

Axis nsmap.properties

Mapping namespaces from a remote WSDL to your package structure

Share

Trying to generate classes from a SOAP WSDL is pretty easy, especially if you are using Ant. You simply run the axis-wsdl2java task and you get the stub classes. The problem is that if your WSDL file looks like this:


<wsdl :definitions
targetNamespace="http://localhost/axis/services/MyService">
</wsdl>
<schema targetNamespace="http://myservice.yzukerman.cscie162.harvard">

The classes will be generated into two directories:

  • The Axis infrastructure classes will be generated into:

    localhost/axis/services/MyService

    Which corresponds to the WSDL URL

  • The service stubs will be generated into:
    harvard/cscie162/yzukerman/myservice

    which is in the reverse order of the namespace URL

To overcome that, Axis can use a namespace mapping file, nsmap.properties which maps the namespace names into the package names you want each of the remote namespaces (Axis classes, stub classes) to be generated into. So, for the above files to both be mapped under a package called com.enavigo.myservice, the nsmap will look like this:

http\://myservice.yzukerman.cscie162.harvard=
com.enavigo.myservice

http\://localhost/axis/services/MyService=com.enavigo.myservice

My co-worker Nate Pickett helped me with this ‘discovery’.

Look at this JavaWorld article to more.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Share