Wsimport Two Ads Cause Collision
I am trying to use wsimport at 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
And here's the mistake.
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)
I searched around StackOverflow and found wsimport. The two declarations cause a collision, the same as stated , but this is from 4 years ago and I don't know, the resolution still applies. The recommendation was to remove the -p which I did, but I am still getting the error above. Any ideas on what I am doing wrong? I can hook up wsdl to SoapUI and generate test stubs, but I just can't handle the wsimport hump.
UPDATE 1 I've also tried using schema binding.
<?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>
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 getting the same error as above.
UPDATE 2 Finally, the following updates have been resolved.
<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>
I'm not 100% sure if this is the best or even the correct resolution, but the errors are gone and the code is generated.
source to share
Here is the last 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
And here is the custom bound xml. Hope this helps someone else. It 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>
source to share