您好我使用Spring Integration WS Outbound网关来调用Soap服务。这是WSDL:
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CreatePreadvice" targetNamespace="http://www.asda.com/CreatePreadvice/" xmlns:isd="http://www.asda.com/CreatePreadvice/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://www.asda.com/CreatePreadvice/" xmlns:Q1="http://www.asda.com/PreadviceRequest">
<xsd:import schemaLocation="Preadvice.xsd" namespace="http://www.asda.com/PreadviceRequest"></xsd:import>
<xsd:element name="createPreadvice">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceRequest" type="Q1:Preadvice"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="createPreadviceResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceResponse" type="isd:Response"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Response">
<xsd:sequence>
<xsd:element name="ResponseCode" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="createPreadviceFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="parcelInjectionFault"
type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="createPreadviceFault1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceResponse"
type="isd:Fault">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Fault">
<xsd:sequence>
<xsd:element name="ResponseCode" type="xsd:string"></xsd:element>
<xsd:element name="Error" type="isd:Error"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Error">
<xsd:sequence>
<xsd:element name="ErrorCode" type="xsd:string"></xsd:element>
<xsd:element name="Description" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<wsdl:message name="createPreadviceRequest">
<wsdl:part element="isd:createPreadvice" name="parameters"/>
</wsdl:message>
<wsdl:message name="createPreadviceResponse">
<wsdl:part element="isd:createPreadviceResponse" name="parameters"/>
</wsdl:message>
<wsdl:message name="createPreadviceFault">
<wsdl:part name="parameters" element="isd:createPreadviceFault"></wsdl:part>
</wsdl:message>
<wsdl:message name="createPreadviceFault1">
<wsdl:part name="parameters" element="isd:createPreadviceFault1"></wsdl:part>
</wsdl:message>
<wsdl:portType name="CreatePreadvice">
<wsdl:operation name="createPreadvice">
<wsdl:input message="isd:createPreadviceRequest"/>
<wsdl:output message="isd:createPreadviceResponse"/>
<wsdl:fault name="fault" message="isd:createPreadviceFault1"></wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CreatePreadviceSOAP" type="isd:CreatePreadvice">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="createPreadvice">
<soap:operation soapAction="http://www.asda.com/CreatePreadvice/createPreadvice"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CreatePreadvice">
<wsdl:port binding="isd:CreatePreadviceSOAP" name="CreatePreadviceSOAP">
<soap:address location="http://161.163.98.135:60719/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
这是从我用于从JAXB创建映射对象的wsdl类型中获取的xsd
<xsd:schema targetNamespace="http://www.asda.com/CreatePreadvice/"
xmlns:Q1="http://www.asda.com/PreadviceRequest"
xmlns:isd="http://www.asda.com/CreatePreadvice/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import schemaLocation="Preadvice_new.xsd"
namespace="http://www.asda.com/PreadviceRequest"></xsd:import>
<xsd:element name="createPreadvice">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceRequest" type="Q1:Preadvice" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="createPreadviceResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceResponse" type="isd:Response" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Response">
<xsd:sequence>
<xsd:element name="ResponseCode" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="createPreadviceFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="parcelInjectionFault" type="xsd:string">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="createPreadviceFault1">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CreatePreadviceResponse" type="isd:Fault">
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="Fault">
<xsd:sequence>
<xsd:element name="ResponseCode" type="xsd:string"></xsd:element>
<xsd:element name="Error" type="isd:Error"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Error">
<xsd:sequence>
<xsd:element name="ErrorCode" type="xsd:string"></xsd:element>
<xsd:element name="Description" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
这是弹簧集成配置
<int:chain input-channel="createPreadviceServiceRequestChannel"
output-channel="createPreadviceServiceReplyChannel">
<ws:header-enricher>
<ws:soap-action value="http://www.asda.com/CreatePreadvice/createPreadvice" />
</ws:header-enricher>
<ws:outbound-gateway
uri="${returndropoff.parceldroppost.createpreadvice.stubUrl}"
marshaller="jaxbsoapunmarshaller" unmarshaller="jaxbsoapunmarshaller" />
</int:chain>
<bean id="jaxbsoapunmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound"
value="com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Preadvice,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Address,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.ClientDetails,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Consignee,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Consignment,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Consignments,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Consignor,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.ConsumerDetails,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Contact,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Container,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Containers,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Contents,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Header,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Message,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.ParcelAttributes,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Services,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.CreatePreadvice,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.CreatePreadviceFault,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.CreatePreadviceFault1,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.CreatePreadviceResponse,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Error,
com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Fault,com.asda.connect.returnanddropoffs.dto.post.createpreadvice.Response" />
</bean>
和returndropoff.parceldroppost.createpreadvice.stubUrl是端点url.Can任何人都可以帮助解决问题。为什么我得到的InputStream不代表WS网关的有效SOAP 1.1消息异常。
异常Stacktrace
Caused by: javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.1 Message
at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:88)
at com.sun.xml.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:143)
at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:189)
... 279 more
答案 0 :(得分:0)
SaajSoapMessageFactory
默认使用 SOAP 1.1 。确保服务响应位于适当的版本或 1.2 。如果是最后一个,您应该将SaajSoapMessageFactory
bean注入<ws:outbound-gateway>
并使用适当的属性:
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"
p:payloadCaching="true"
p:soapVersion="#{T(org.springframework.ws.soap.SoapVersion).SOAP_12}"/>