我无法使用wsimport为GetHotelMediaRQ生成wsdl JAVA。你能告诉我如何解决这个问题吗?
wsimport -target 2.1 -keep -d /Users/jinli/Tmp/ws/classes -s . -p org.jellylab.soap.sacs.proto 'http://webservices.sabre.com/wsdl/sabreXML1.0.00/VCMP/GetHotelMediaRQ_v2.0.0.wsdl'
parsing WSDL...
[ERROR] 'HotelMediaInfos' is already defined
line 51 of http://webservices.sabre.com/wsdl/sabreXML1.0.00/VCMP/GetHotelMediaRS_v2.0.0.xsd
[ERROR] (related to above error) the first definition appears here
line 390 of http://webservices.sabre.com/wsdl/sabreXML1.0.00/VCMP/HotelMediaCommons_v2.0.0.xsd
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:497)
at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:159)
at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)
答案 0 :(得分:1)
错误是正确的,这被定义了2次。您需要下载WSDL和所有关联的模式。
GetHotelMediaRS_v2.0.0.xsd
看起来像xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:stlp="http://services.sabre.com/STL_Payload/v02_02" xmlns="http://services.sabre.com/hotel/media/v2" targetNamespace="http://services.sabre.com/hotel/media/v2" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://services.sabre.com/STL_Payload/v02_02" schemaLocation="built-ins/STL2_Payload_v02_02.xsd" />
<xs:include schemaLocation="HotelMediaCommons_v2.0.0.xsd" />
<xs:element name="GetHotelMediaRS">
<xs:annotation>
<xs:documentation xml:lang="en">
Hotel Media Response Message provides hotel media content available for the specified hotel property code.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="stlp:STL_Response_Payload">
<xs:sequence>
<xs:element name="HotelMediaInfos" type="HotelMediaInfos">
<xs:annotation>
<xs:documentation xml:lang="en">
Contains information about one or more hotel codes and corresponding available media types.
This depends on the hotel codes provided in the request.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="HotelMediaInfos">
<xs:annotation>
<xs:documentation xml:lang="en">
Contains information about one or more hotel codes and corresponding available media types.
This depends on the hotel codes provided in the request.
</xs:documentation>
</xs:annotation>
<xs:sequence minOccurs="0" maxOccurs="50">
<xs:element name="HotelMediaInfo" type="HotelMediaInfo">
<xs:annotation>
<xs:documentation xml:lang="en">
Contains infroamtion about various media types available for a particular hotel code.
This depends on the hotel code provided in the request.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
您应该只删除complexType
定义HotelMediaInfos
,最终会出现类似下面的内容:xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:stlp="http://services.sabre.com/STL_Payload/v02_02" xmlns="http://services.sabre.com/hotel/media/v2" targetNamespace="http://services.sabre.com/hotel/media/v2" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://services.sabre.com/STL_Payload/v02_02" schemaLocation="built-ins/STL2_Payload_v02_02.xsd" />
<xs:include schemaLocation="HotelMediaCommons_v2.0.0.xsd" />
<xs:element name="GetHotelMediaRS">
<xs:annotation>
<xs:documentation xml:lang="en">
Hotel Media Response Message provides hotel media content available for the specified hotel property code.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="stlp:STL_Response_Payload">
<xs:sequence>
<xs:element name="HotelMediaInfos" type="HotelMediaInfos">
<xs:annotation>
<xs:documentation xml:lang="en">
Contains information about one or more hotel codes and corresponding available media types.
This depends on the hotel codes provided in the request.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
您甚至可以替换GetHotelMediaRS_v2.0.0.xsd
中的上述内容,您应该可以编译。
个人推荐,将来尝试自己做这些事情。它将帮助您学习并避免依赖Sabre或社区。 p>