我有以下wsdl
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:ota="http://www.opentravel.org/OTA/2003/05"
targetNamespace="http://www.opentravel.org/OTA/2003/05"
name="OCDistributorsService">
<types>
<xs:schema>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelSearchRQ.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelSearchRS.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelDescriptiveInfoRQ.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelDescriptiveInfoRS.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelAvailRQ.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelAvailRS.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelResRQ.xsd"/>
<xs:import namespace="http://www.opentravel.org/OTA/2003/05" schemaLocation="xsd/OTA_HotelResRS.xsd"/>
</xs:schema>
</types>
<message name="ListPropertiesRequest">
<part name="request" element="ota:OTA_HotelSearchRQ"/>
</message>
<message name="ListPropertiesResponse">
<part name="response" element="ota:OTA_HotelSearchRS"/>
</message>
<message name="GetPropertyDetailsRequest">
<part name="request" element="ota:OTA_HotelDescriptiveInfoRQ"/>
</message>
<message name="GetPropertyDetailsResponse">
<part name="response" element="ota:OTA_HotelDescriptiveInfoRS"/>
</message>
<message name="GetMultiAvailabilityRequest">
<part name="request" element="ota:OTA_HotelAvailRQ"/>
</message>
<message name="GetMultiAvailabilityResponse">
<part name="response" element="ota:OTA_HotelAvailRS"/>
</message>
<message name="GetSingleAvailabilityRequest">
<part name="request" element="ota:OTA_HotelAvailRQ"/>
</message>
<message name="GetSingleAvailabilityResponse">
<part name="response" element="ota:OTA_HotelAvailRS"/>
</message>
<message name="CheckAvailabilityRequest">
<part name="request" element="ota:OTA_HotelAvailRQ"/>
</message>
<message name="CheckAvailabilityResponse">
<part name="response" element="ota:OTA_HotelAvailRS"/>
</message>
<message name="DoReservationRequest">
<part name="request" element="ota:OTA_HotelResRQ"/>
</message>
<message name="DoReservationResponse">
<part name="response" element="ota:OTA_HotelResRS"/>
</message>
<portType name="OCDistributorsV1Port">
<operation name="ListProperties">
<input message="ota:ListPropertiesRequest"/>
<output message="ota:ListPropertiesResponse"/>
</operation>
<operation name="GetPropertyDetails">
<input message="ota:GetPropertyDetailsRequest"/>
<output message="ota:GetPropertyDetailsResponse"/>
</operation>
<operation name="GetMultiAvailability">
<input message="ota:GetMultiAvailabilityRequest"/>
<output message="ota:GetMultiAvailabilityResponse"/>
</operation>
<operation name="GetSingleAvailability">
<input message="ota:GetSingleAvailabilityRequest"/>
<output message="ota:GetSingleAvailabilityResponse"/>
</operation>
<operation name="CheckAvailability">
<input message="ota:CheckAvailabilityRequest"/>
<output message="ota:CheckAvailabilityResponse"/>
</operation>
<operation name="DoReservation">
<input message="ota:DoReservationRequest"/>
<output message="ota:DoReservationResponse"/>
</operation>
</portType>
<binding name="OCDistributorsV1POST" type="ota:OCDistributorsV1Port">
<http:binding verb="POST"/>
<operation name="ListProperties">
<http:operation location="ListProperties"/>
<input/>
<output/>
</operation>
<operation name="GetPropertyDetails">
<http:operation location="GetPropertyDetails"/>
<input/>
<output/>
</operation>
<operation name="GetMultiAvailability">
<http:operation location="GetMultiAvailability"/>
<input/>
<output/>
</operation>
<operation name="GetSingleAvailability">
<http:operation location="GetSingleAvailability"/>
<input/>
<output/>
</operation>
<operation name="CheckAvailability">
<http:operation location="CheckAvailability"/>
<input/>
<output/>
</operation>
<operation name="DoReservation">
<http:operation location="DoReservation"/>
<input/>
<output/>
</operation>
</binding>
<service name="OCDistributorsServiceV1">
<port name="POST" binding="ota:OCDistributorsV1POST">
<http:address location="http://sandbox-api-distributors.odigeoconnect.com/distributors/v1/"/>
</port>
</service>
我正在使用 jaxws-maven-plugin 自动生成我的客户端类。我的maven插件配置如下:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<configuration>
<sei/>
<verbose>true</verbose>
<extension>true</extension>
<packageName>com.odigeo.accommodation.fare.provider.odigeoconnect.generated</packageName>
<wsdlDirectory>${project.basedir}/src/main/conf/resources</wsdlDirectory>
<sourceDestDir>${project.basedir}/src/main/gen-java</sourceDestDir>
<wsdlFiles>
<wsdlFile>com/odigeo/accommodation/fare/provider/odigeoconnect/odigeoconnect.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${project.basedir}/src/main/conf/resources/com/odigeo/accommodation/fare/provider/odigeoconnect</bindingDirectory>
<bindingFiles>
<bindingFile>bindings.xjb</bindingFile>
</bindingFiles>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
</plugin>
问题是,当我尝试调用 WS 时,使用生成的 ServiceClient 提供端口,如下所示:
final OTAHotelAvailRS response = port.getSingleAvailability(request);
我收到以下错误:
Cannot create SOAP envelope from: {http://www.opentravel.org/OTA/2003/05}OTA_HotelAvailRS
所以,wsdl 明确指出请求是 HTTP POST,那么为什么我生成的客户端试图将响应解析为 SOAP?服务器的响应是有效的 XML。