Я уже решил проблему с помощью параметра -p в командной строке wsdl2java, чтобы поместить конфликт пространства имен в другой пакет, но после того, как я попытался, я не смог сделать это с помощью привязки JAXB.
Как правильно использовать переплет?
У меня есть следующий wsdl:
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions targetNamespace="http://com.foo.ws/FicherosVehiculosWS/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ax21="http://com.foo.ws/FicherosVehiculosWS/xsd" xmlns:tns="http://com.foo.ws/FicherosVehiculosWS/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl">
<wsdl:documentation>FicherosVehiculosWS</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://com.foo.ws/FicherosVehiculosWS/">
<xs:import namespace="http://com.foo.ws/FicherosVehiculosWS/xsd"/>
<xs:element name="consultaMarcasRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="ax21:claveSubtipoVehiculo"/>
<xs:element minOccurs="0" ref="ax21:claveCategoriaCirculacion"/>
<xs:element minOccurs="0" ref="ax21:claveGrupoEstadistico"/>
<xs:element minOccurs="0" ref="ax21:claveClasificacion"/>
<xs:element minOccurs="0" ref="ax21:modelo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="consultaMarcasResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="ax21:marcas"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://com.foo.ws/FicherosVehiculosWS/">
<xs:import namespace="http://com.foo.ws/FicherosVehiculosWS/xsd"/>
<xs:element name="consultaSubtipoVehiculoResponse">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="tns:subtipoVehiculo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="subtipoVehiculo">
<xs:complexType>
<xs:sequence>
<xs:element ref="ax21:claveSubtipoVehiculo"/>
<xs:element ref="tns:descSubtipoVehiculo"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="claveSubtipoVehiculo" type="xs:string"/>
<xs:element name="descSubtipoVehiculo" type="xs:string"/>
</xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://com.foo.ws/FicherosVehiculosWS/xsd">
<xs:element name="marcas">
<xs:complexType>
<xs:sequence>
<xs:element ref="ax21:claveMarca"/>
<xs:element minOccurs="0" name="descMarca" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="version">
<xs:complexType>
<xs:sequence>
<xs:element name="claveVersion" type="xs:string"/>
<xs:element name="descVersion" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="descripcion" type="xs:string"/>
<xs:element name="claveClasificacion" type="xs:string"/>
<xs:element name="modelo" type="xs:int"/>
<xs:element name="claveSubtipoVehiculo" type="xs:string"/>
<xs:element name="claveCategoriaCirculacion" type="xs:integer"/>
<xs:element name="claveGrupoEstadistico" type="xs:integer"/>
<xs:element name="claveMarca" type="xs:string"/>
<xs:element name="descClasificacion" type="xs:string"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="consultarMarcasRequest">
<wsdl:part name="parameters" element="tns:consultaMarcasRequest"/>
</wsdl:message>
<wsdl:message name="consultarMarcasResponse">
<wsdl:part name="parameters" element="tns:consultaMarcasResponse"/>
</wsdl:message>
<wsdl:portType name="FicherosVehiculosWSPortType">
<wsdl:operation name="consultarMarcasOperation">
<wsdl:input message="tns:consultarMarcasRequest" wsaw:Action="http://com.foo.ws/FicherosVehiculosWS/consultarMarcasOperation"/>
<wsdl:output message="tns:consultarMarcasResponse" wsaw:Action="http://com.foo.ws/FicherosVehiculosWS/FicherosVehiculosWSPortType/consultarMarcasOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="FicherosVehiculosWSSOAP" type="tns:FicherosVehiculosWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="consultarMarcasOperation">
<soap:operation soapAction="http://com.foo.ws/FicherosVehiculosWS/consultarMarcasOperation" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FicherosVehiculosWS">
<wsdl:port name="FicherosVehiculosWSSOAP" binding="tns:FicherosVehiculosWSSOAP">
<soap:address location="http://com.foo.ws/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Схема FicherosVehiculosWS
и FicherosVehiculosWS/xsd
ссылаются на одно и то же свойство claveSubtipoVehiculo
, и происходит столкновение.
Я попробовал следующие три решения переопределить проблему, используя привязку JAXB, только для того, чтобы получить ту же ошибку, но на этот раз как ошибку JAXB Throw. Что я сделал не так?
Шаблон 1
<?xml version="1.0" encoding="utf-8"?>
<jaxws:bindings wsdlLocation="http://127.0.0.1/FicherosVehiculosWS.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://com.foo.ws/FicherosVehiculosWS/xsd']">
<jxb:package name="mx.axa.ventadirecta.stub.bancs.ficheroauto.xsd"/>
</jaxws:bindings>
</jaxws:bindings>
Шаблон 2
<?xml version="1.0" encoding="utf-8"?>
<jaxws:bindings wsdlLocation="http://127.0.0.1/FicherosVehiculosWS.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://com.foo.ws/FicherosVehiculosWS/xsd']">
<!-- Customize the package name that is generated for each schema -->
<jxb:bindings node="//xs:element[@name='claveSubtipoVehiculo']">
<!-- rename the value element -->
<nameXmlTransform>
<xs:element maxOccurs="unbounded" ref="ax21:subtipoVehiculo"/>
</nameXmlTransform>
</jxb:bindings>
</jaxws:bindings>
</jaxws:bindings>
Шаблон 3
<?xml version="1.0" encoding="utf-8"?>
<jaxws:bindings wsdlLocation="http://127.0.0.1/FicherosVehiculosWS.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://com.foo.ws/FicherosVehiculosWS/xsd']">
<!-- Customize the package name that is generated for each schema -->
<jxb:bindings node="//xs:element[@name='consultaSubtipoVehiculoResponse']//xs:complexType//xs:sequence//xs:element[@ref='tns:subtipoVehiculo']">
<!-- rename the value element -->
<jxb:class name="DescSubtipoVehiculo" />
</jxb:bindings>
</jaxws:bindings>
</jaxws:bindings>