有哪些分享一些他们使用来定义自己的数据类型模式两个WSDL中。这里是WSDL中的一个的示例:
<wsdl:definitions
name="FooService"
targetNamespace="http://xmlns.my.org/services/FooService/v001"
xmlns:srv="http://xmlns.my.org/services/FooService/v001"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:fault="java:org.my.exception"
...
>
<wsdl:types>
<xsd:schema>
<xsd:import namespace="java:org.my.exception" schemaLocation="../xsd/common/BusinessException.xsd"/>
<xsd:import namespace="http://xmlns.my.org/services/FooServiceMessages/v001" schemaLocation="../xsd/fooservice/FooServiceMessages_v001.xsd"/>
</xsd:schema>
</wsdl:types>
...
<wsdl:message name="BusinessException">
<wsdl:part element="fault:BusinessException" name="BusinessException"/>
</wsdl:message>
...
<wsdl:portType name="IFooService">
<wsdl:operation name="getItems">
...
<wsdl:fault message="srv:BusinessException" name="BusinessException"/>
</wsdl:operation>
...
</wsdl:portType>
...
</wsdl:definitions>
BusinessException.xsd
是常见方案中的一个。
我试图产生这些的WSDL与wsimport
Java代码。这将是合理的,从WSDLd分别编译常见的模式,然后再用在编译的WSDL从这些模式派生类。为此我已经生成与普通的Java代码沿JAXB插曲文件:
<bindings version="2.1" xmlns="http://java.sun.com/xml/ns/jaxb">
<bindings scd="x-schema::tns" xmlns:tns="java:org.my.exception">
<schemaBindings map="false">
<package name="org.my.integration.dto.common"/>
</schemaBindings>
<bindings scd="~tns:BusinessException">
<class ref="org.my.integration.dto.common.BusinessException"/>
</bindings>
</bindings>
<bindings scd="x-schema::tns" xmlns:tns="http://xmlns.my.org/BaseIdentifiers/v001">
<schemaBindings map="false">
<package name="org.my.integration.dto.common"/>
</schemaBindings>
<bindings scd="~tns:EntityIdentifierListType">
<class ref="org.my.integration.dto.common.EntityIdentifierListType"/>
</bindings>
<bindings scd="~tns:...">
<class ref="..."/>
</bindings>
...
</bindings>
</bindings>
http://xmlns.my.org/BaseIdentifiers/v001
命名空间充满了在FooServiceMessages_v001.xsd
进口(实际上在在一个架构这...这是在FooServiceMessages_v001.xsd
进口导入的架构)的另一种常见的模式。
下面是我用它来生成Java代码的wsimport电话:
wsimport -B-XautoNameResolution -Xnocompile -s ./../java/ -verbose -b ./bindings/fooservice/jaxws-bindings.xml -b ./bindings/fooservice/jaxb-bindings.xml -b ./bindings/common/common.episode -keep ./wsdl/FooService_v001.wsdl
在此调用出现以下错误:
[ERROR] Schema descriptor {java:org.my.exception}BusinessException in message part "BusinessException" is not defined and could not be bound to Java. ...
顺便说一句,如果用于BusinessException.xsd
绑定在一个普通的外部JAXB绑定文件描述(不是在一个小插曲文件)一切工作正常。看起来wsimport
有一些问题,处理其描述绑定它们在WSDL直接导入方案插曲文件。
有没有办法使用片段文件与wsimport
的方案直接进口的WSDL(就像我的情况BusinessException.xsd
)的方法吗?
看来,这是某种错误或wsimport的不正确的行为。 Apache的CXF WSDL2Java工具缺乏这方面的问题。
作为https://github.com/javaee/jaxb-v2/issues/514说,这是不可能产生使用JAXB发作的WSDL源。
太阳/ Oracle的工程师无法实施必要的措施增强了11年(2008至19年)。而近日甲骨文抛出源到Eclipse项目(2018年10月)。
我生成WSDL没有发作结合,作为最后一步,我删除从公共架构包。对于摇篮,它看起来像:
wsimport {
wsdl = file("${project.rootDir}/wsdl/PingService.wsdl")
bindings = files(...)
}
task('afterWsimport', type: Delete) {
delete new File(file(wsimport.javaDir), "com/bla/schema")
delete new File(file(wsimport.javaDir), "com/foo")
}
wsimport.finalizedBy(afterWsimport)