I have a wsdl
with an embedded xsd
.
<wsdl:definitions name="AcmeService"
targetNamespace="http://www.acme.com/services/Acme/WcfService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://www.acme.com/services/Acme/WcfService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://www.acme.com/services/Acme/WcfService/Imports">
<xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd0" namespace="http://www.acme.com/services/Acme/WcfService" />
<xsd:import schemaLocation="http://services01.acme.com/WebServices/AcmeWcfClient/service/AcmeService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
<!-- Some more WSDL Content -->
</wsdl:definitions>
My 'xsd' contains the following definitions:
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.acme.com/services/Acme/WcfService">
<xs:element name="SetApplication">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="application" nillable="true" type="tns:Application"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="Application">
<xs:sequence>
<xs:element minOccurs="0" name="SomeElement" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="AnotherElement" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="AcmeDetails" nillable="true" type="tns:Acme"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Application" nillable="true" type="tns:Application"/>
<xs:complexType name="Acme">
<xs:sequence>
<xs:element minOccurs="0" name="PropertyOne" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="PropertyTwo" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Acme" nillable="true" type="tns:Acme"/>
<xs:element name="GetAcmeDetails">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="acme" nillable="true" type="tns:Acme"/> <!-- "acme" name is lowercase on purpose -->
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetAcmeDetailsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="GetAcmeDetailsResult" nillable="true" type="tns:Acme"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My problem comes from the fact that, when generating the service stubs using wsimport, I am left with the following definition for Acme
:
@XmlType(name = "Acme", namespace = "http://www.acme.com/services/Acme/WcfService", propOrder = {
The issue being that I need both Acme
and AcmeDetails
to resolve to the same underlying Acme
object.
Looking at a couple of other, similar, questions (here, here, and here) I have tried to create a binding using the following XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
wsdlLocation="Acme_Service.wsdl">
<enableWrapperStyle>true</enableWrapperStyle>
<enableAsyncMapping>false</enableAsyncMapping>
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema/xs:complexType[@name='Application']/xs:sequence/xs:element[@name='AcmeDetails']">
<jaxb:class name="AcmeDetails"/>
</jaxws:bindings>
</jaxws:bindings>
The above binding generates the class 'AcmeDetails' but the XMLType Annotation remains 'Acme'.
Any help in generating bindings to both Acme
and AcmeDetails
in the above extract greatly appreciated.
External XML schema files imported by the WSDL file can be customized using a JAXB external binding declaration file:
<jxb:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="1.0">
<jxb:bindings schemaLocation="your-imported-xsd-location" node="/xsd:schema">
<jxb:schemaBindings>
<jxb:package name="fromjava.client"/>
</jxb:schemaBindings>
</jxb:bindings>
...
</jxb:bindings>
The external JAXB binding declaration file can be passed to wsimport using the -b switch. See the JAX-WS tools documentation for details.
The above excerpt comes from this link; while most likely applicable for your version, you could double check the same;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With