wsdl with conflicting xsd imports

↘锁芯ラ 提交于 2020-01-06 15:29:33

问题


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:

<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>

using: wsimport -p org.wsi -b testbindings.jaxb broker.wsdl

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>

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.

Suggestions are welcome.


回答1:


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 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>


来源:https://stackoverflow.com/questions/12707336/wsdl-with-conflicting-xsd-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!