Define a custom namespace to map packages of a generated file from wsdl - Axis2 eclipse

I have a wsdl file in Eclipse and I generate the client through the axis2 plugin.

Files are created in the com.mycompany.stub package in the source folder.

I would like to change the package names of the generated source files to com.mycompany.ws.workflow

Where can I do this in a wsdl file?

+4
source share
1 answer

You really don't need to modify wsdl for this. If you use the Eclipse Helios Web Service Client Wizard, in the second step (optional), where you specify the output folder for the generated source, check the box "Define custom mapping for namespace for packaging". Select this field and in the following form you can define your custom package associations.

EDIT 1:

Link to Official Documentation

EDIT 2:

Wsdl

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://mycompany.com/MyService.wsdl" xmlns:scm="http://mycompany.com/MyService.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://mycompany.com/MyService.wsdl"> ... 

For a simple wsdl, as shown above, the user mapping will look like this.

http://mycompany.com/MyService.wsdl - com.mycompany.ws.workflow http://mycompany.com/MyService.xsd - com.mycompany.ws.workflow.schema

You can click "Add" and enter the namespace and package names, or you can save the display in the properties file and click "Import" to add it all at once. I prefer the properties file. You should also avoid namespace URLs and other special characters if you intend to use a properties file. Your properties file should look like the one below.

nsmapping.properties

http\://mycompany.com/MyService.wsdl=com.mycompany.ws.workflow http\://mycompany.com/MyService.xsd=com.mycompany.ws.workflow.schema

Excerpt from official documentation.

The contents of the properties file must be in the format namespace = package. You will need to avoid some special characters in the property files. For example, http: // someNamespace = somePackage should be http: // someNamespace = somePackage. Otherwise, the colon (:) will be considered as a separator, which will lead to an attempt to match http with // someNamespace = somePackage.

+9
source

Source: https://habr.com/ru/post/1338232/


All Articles