问题描述
我试图在一段时间内找到解决方案以解决以下问题。我有一个包含几(6)个xsd导入的wsdl文件。我无法更改这些xsd,因为它们是我项目的外部。共有4个定义,这些定义在这些模式中的2个中略有不同。我试图将每个'冲突'的xsd架构转换为它自己的包。我尝试了以下绑定,但它没有完成这项工作:
I tried to find a solution for some time to the following problem. I have a wsdl file containing several (6) xsd imports. I cannot change these xsd's because they are external to my project. There are 4 definitions all together which are slightly defined different in 2 of these schemas. I was attempting to translate each 'conflicting' xsd schema to it's own package. I tried following bindings, but it did not do the job:
testbindings.jaxb:
testbindings.jaxb:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.1">
<bindings schemaLocation="a.xsd">
<schemaBindings>
<package name="org.wsi.a" />
</schemaBindings>
</bindings>
</bindings>
使用: wsimport -p org.wsi -b testbindings.jaxb broker。 wsdl
所有类都是在 org.wsi
中生成的,并且 org.wsi.a
。如果没有-p开关,则所有xsd都在其自己的默认包中生成。但无法告诉wsimport为每个xsd使用特定的包。此时我使用以下绑定文件,这可能不正确,但wsimport没有抱怨:
All classes are generated in org.wsi
and no classes in org.wsi.a
. Without the -p switch all xsd are generated in their own default package. But could not tell wsimport to use specific packages for each xsd. At this moment I use following binding file, which is probably incorrect, but for which the wsimport doesn't complain:
<?xml version="1.0"?>
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
<jaxws:bindings wsdlLocation="broker.wsdl" node="wsdl:definitions/wsdl:types/xsd:schema">
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" node="//xs:schema/xs:import[@namespace='http://docs.oasis-open.org/wsn/b-2']">>
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.b_2"/>
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" node="//xs:schema/xs:import[@namespace='http://docs.oasis-open.org/wsn/t-1']">>
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.t_1"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxws:bindings>
在包org.broker中。 wsi.b_2和org.broker.wsi.t_1,没有生成任何文件。
In packages org.broker.wsi.b_2 and org.broker.wsi.t_1, no files are generated.
我使用了以下指定的绑定:但可能不正确。
I used bindings as specified in: http://docs.oracle.com/cd/E13222_01/wls/docs103/webserv/data_types.html#wp227713 but probably incorrect.
欢迎提出建议。
推荐答案
问题/答案中描述了为wsdl,内部xsd和外部xsd设置正确包名的问题:
The problem of setting up the correct package names for the wsdl, the internal xsd and the external xsd's is described in question/answer:
- ,发布者:
- wsimport - how to generate service endpoint classes and JAXB classes in separate projects/folders, posted by:dma-k
int-bindings.xml文件:
int-bindings.xml file:
<?xml version="1.0"?>
<jaxws:bindings version="2.0"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
wsdlLocation="broker.wsdl">
<jaxws:package name="org.broker.wsi" />
<jaxb:bindings node="//xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.al"/>
</jaxb:schemaBindings>
</jaxb:bindings>
外部绑定文件(缩写):
The external-bindings file (abbreviated):
<jaxb:bindings version="1.0"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="http://docs.oasis-open.org/wsn/b-2.xsd" node="//xsd:schema">
<jaxb:schemaBindings>
<jaxb:package name="org.broker.wsi.oasis.b2"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
这篇关于wsdl与xsd导入冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!