简体   繁体   English

定义自定义命名空间以封装来自wsdl - Axis2 eclipse的生成文件的映射

[英]Define the custom namespace to package mapping of generated file from wsdl - Axis2 eclipse

I have wsdl file in Eclipse and I am generating the client via axis2 plugin. 我在Eclipse中有wsdl文件,我通过axis2插件生成客户端。

The files are being generated to a package called com.mycompany.stub in source folder. 这些文件正生成到源文件夹中名为com.mycompany.stub的包中。

I would like to change the package names of the generated source files to com.mycompany.ws.workflow 我想将生成的源文件的包名称更改为com.mycompany.ws.workflow

Where can I do it in the wsdl file? 我在哪里可以在wsdl文件中执行此操作?

You don't really have to modify wsdl to achieve this. 您实际上不必修改wsdl来实现此目的。 If you are using Eclipse Helios Web service Client Wizard, On the second step (optional) where you specify output folder for generated source, there's a checkbox for 'Define custom mapping for namespace to package.'. 如果您正在使用Eclipse Helios Web服务客户端向导,则在为生成的源指定输出文件夹的第二步(可选)中,有一个“定义命名空间到包的自定义映射”的复选框。 Select that box and on the next form you can define your custom package mappings. 选择该框,然后在下一个表单上定义自定义包映射。

EDIT 1: 编辑1:

Link to the Official Documentation 链接到官方文档

EDIT 2: 编辑2:

WSDL 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 simple wsdl as shown above, custom mapping would look like as below. 对于如上所示的简单wsdl,自定义映射将如下所示。

http://mycompany.com/MyService.wsdl - com.mycompany.ws.workflow http://mycompany.com/MyService.xsd - com.mycompany.ws.workflow.schema 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 name-space and package names or you can store mapping in properties file and click import to add it all at once. 您可以单击“添加”并输入名称空间和包名称,也可以在属性文件中存储映射,然后单击“导入”以立即添加全部。 I prefer properties file. 我更喜欢属性文件。 Also you have to escape the name space URL and other special characters if you are going to use properties file. 如果要使用属性文件,还必须转义名称空间URL和其他特殊字符。 Your properties file should look similar to below. 您的属性文件应类似于下面的内容。

nsmapping.properties nsmapping.properties

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

Excerpt from official documentation. 摘自官方文件。

The content of the properties file must be of the format namespace=package. 属性文件的内容必须是namespace = package格式。 You will need to escape some special characters in the properties files. 您需要转义属性文件中的一些特殊字符。 For example http://someNamespace=somePackage should be http://someNamespace=somePackage. 例如, http:// someNamespace = somePackage应为http:// someNamespace = somePackage。 Otherwise, the colon (:) would be treated as delimiter resulting in trying to map http to //someNamespace=somePackage. 否则,冒号(:)将被视为分隔符,导致尝试将http映射到// someNamespace = somePackage。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM