本文介绍了wsimport两个声明导致冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在。这是我正在使用的wsimport。

I am trying to use wsimport on https://api.sendwordnow.com/webservices/v3/users.svc?wsdl. Here is the wsimport I am using.

wsimport -B-XautoNameResolution -d C:\temp -extension -J-Djavax.xml.accessExternalSchema=all -J-Djavax.xml.accessExternalDTD=all -keep -verbose -XadditionalHeaders -Xnocompile https://api.sendwordnow.com/webservices/v3/users.svc?wsdl

这是错误。

解析WSDL ...

parsing WSDL...

    [WARNING] unknown extensibility element or attribute "EndpointReference"
    (in namespace "http://www.w3.org/2005/08/addressing") line 1 of
    https://api.sendwordnow.com/webservices/v3/users.svc?wsdl
    [ERROR] Two declarations cause a collision in the ObjectFactory class.
    line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3
    [ERROR] (Related to above error) This is the other declaration.
    line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3
    [ERROR] Two declarations cause a collision in the ObjectFactory class.
    line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2
    [ERROR] (Related to above error) This is the other declaration.
    line 1 of https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2
    Exception in thread "main" com.sun.tools.internal.ws.wscompile.AbortException
    at com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:129)at
    com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2283)
    at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:183)
    at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:126)
    at com.sun.tools.internal.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:429)
    at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:190)
    at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.java:168)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498) at
    com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159) at
    com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)

我在StackOverflow上搜索并发现但这是4年前我不知道如果决议仍然适用。建议删除我做的-p但我仍然收到上面的错误。关于我做错的任何想法?我可以将wsdl插入SoapUI并生成测试存根,但我似乎无法克服wsimport驼峰。

I searched around on StackOverflow and found wsimport - Two declarations cause a collision, same line given but this is from 4 years ago and I don't know if the resolution is still applicable. The recommendation was to remove the -p which I did but I am still receiving the error above. Any ideas on what I am doing wrong? I can plug the wsdl into SoapUI and generate testing stubs but I just can't seem to get over the wsimport hump.

UPDATE 1
我也尝试过使用架构绑定。

UPDATE 1I have tried using schema binding as well.

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0"
              xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd0">
        <jxb:schemaBindings>
            <jxb:package name="com.users" />
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd1">
        <jxb:schemaBindings>
            <jxb:package name="com.serialization"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv2"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv1"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd4">
        <jxb:schemaBindings>
            <jxb:package name="com.arrays"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd5">
        <jxb:schemaBindings>
            <jxb:package name="com.location"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd6">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv3"/>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

这是更新的wsimport。

Here is the updated wsimport.

wsimport -b "C:\temp\Customization.xml" -B-XautoNameResolution -d C:\temp -extension -J-Djavax.xml.accessExternalSchema=all -J-Djavax.xml.accessExternalDTD=all -keep -verbose -XadditionalHeaders -Xnocompile https://api.sendwordnow.com/webservices/v3/users.svc?wsdl

我仍然收到与上述相同的错误消息。

I am still receiving that same error message as above.

UPDATE 2
最后通过以下更新解决。

UPDATE 2Finally solved with the following updates.

<jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2">
    <jxb:schemaBindings>
        <jxb:package name="com.datacontractsv2"/>
        <jxb:nameXmlTransform>
            <jxb:typeName suffix="Type" />
            <jxb:elementName suffix="Element"/>
        </jxb:nameXmlTransform>
    </jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3">
    <jxb:schemaBindings>
        <jxb:package name="com.datacontractsv1"/>
        <jxb:nameXmlTransform>
            <jxb:typeName suffix="Type" />
            <jxb:elementName suffix="Element"/>
        </jxb:nameXmlTransform>
    </jxb:schemaBindings>
</jxb:bindings>

我不是100%确定这是最佳甚至是正确的解决方案,但错误消失了代码生成。

I'm not 100% sure this is the best or even correct resolution but the errors are gone and code is generated.

推荐答案

这是我用过的最后一个wsimport。

Here is the final wsimport I used.

wsimport -b "C:\temp\Customization.xml" -B-XautoNameResolution -d C:\temp -extension -J-Djavax.xml.accessExternalSchema=all -J-Djavax.xml.accessExternalDTD=all -keep -verbose -XadditionalHeaders -Xnocompile https://api.sendwordnow.com/webservices/v3/users.svc?wsdl

这是自定义绑定xml。我希望这有助于其他人。这真是一个难以解决的问题!

And here is the custom binding xml. I hope this helps someone else. This was a real pain to solve!

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0"
              xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
              xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd0">
        <jxb:schemaBindings>
            <jxb:package name="com.users" />
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd1">
        <jxb:schemaBindings>
            <jxb:package name="com.serialization"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd2">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv2"/>
            <jxb:nameXmlTransform>
                <jxb:typeName suffix="Type" />
                <jxb:elementName suffix="Element"/>
            </jxb:nameXmlTransform>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd3">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv1"/>
            <jxb:nameXmlTransform>
                <jxb:typeName suffix="Type" />
                <jxb:elementName suffix="Element"/>
            </jxb:nameXmlTransform>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd4">
        <jxb:schemaBindings>
            <jxb:package name="com.arrays"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd5">
        <jxb:schemaBindings>
            <jxb:package name="com.location"/>
        </jxb:schemaBindings>
    </jxb:bindings>
    <jxb:bindings schemaLocation="https://api.sendwordnow.com/webservices/v3/Users.svc?xsd=xsd6">
        <jxb:schemaBindings>
            <jxb:package name="com.datacontractsv3"/>
        </jxb:schemaBindings>
    </jxb:bindings>
</jxb:bindings>

这篇关于wsimport两个声明导致冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 18:01