我已经使用wsdl2java命令行中的-p参数解决了问题,将命名空间冲突放在其他包中,但在我尝试之后,我无法使用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>