Skip to end of metadata
Go to start of metadata

Sometimes you want to customize the namespace prefixes in the generated XML documents. There are a few ways to do this.

Note: Technically speaking, it is not necessary to customize the namespace prefixes. Everything should work fine with the autogenerated namespace prefixes, and the generated XML will still be valid. The only reason to customize the namespace prefixes is to make the generated XML look prettier. If you don't care, don't bother.

Step 1: Determine the namespace to customize

You can determine the namespace by looking at the value of the "targetNamespace" attribute on the generated WSDL or schema file. It will be the namespace that is assigned by the annotations or it will be autogenerated.

For example, the namespace for the following WSDL is "http://api.mycompany.com/v1/services/":

The namespace for the following Schema is "http://api.mycompany.com/v1/data/":

And the namespace for the following service endpoint interface is "http://api.mycompany.com/v1/endpoints/":

Step 2: Assign the prefix

You can assign the prefix either by using annotations or my using the Enunciate configuration file.

To use annotations, the prefix can be specified at the package level with a package-info.java file and the @javax.xml.bind.annotation.XmlSchema annotation. The following annotation at the package-level will assign the prefix "services" to the namespace "http://api.mycompany.com/v1/services" and the prefix "data" to the namespace "http://api.mycompany.com/v1/data":

You can also assign a prefix with the Enunciate configuration file:

Labels
  • None