Spring integration Spring Integration WS出站网关错误:InputStream不表示有效的SOAP 1.1消息

Spring integration Spring Integration WS出站网关错误:InputStream不表示有效的SOAP 1.1消息,spring-integration,spring-ws,Spring Integration,Spring Ws,您好,我正在使用Spring Integration WS Outbound gateway调用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/

您好,我正在使用Spring Integration WS Outbound gateway调用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>

SaajSoapMessageFactory
默认使用SOAP 1.1。确保服务响应采用适当的版本或1.2。如果是最后一个,则应使用适当的属性将
SaajSoapMessageFactory
bean注入

<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"
          p:payloadCaching="true"
          p:soapVersion="#{T(org.springframework.ws.soap.SoapVersion).SOAP_12}"/>


是您的
返回dropoff.parceldroppost.createpreadvice.stubUrl
等于
http://161.163.98.135:60719/
用于WSDL中的
地址
?您是否使用SOAP-UI测试了目标服务?看起来您的服务返回无效的
响应
。请分享更多StackTrace,以确保问题取决于响应。嗨,Artem…非常感谢指针…我检查了来自soap客户端的响应,它返回了soap版本1.2的响应,正如SaajSoapMessageFactory默认期望的1.1。为1.2配置了相同的配置,现在工作正常。
<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>
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
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory"
          p:payloadCaching="true"
          p:soapVersion="#{T(org.springframework.ws.soap.SoapVersion).SOAP_12}"/>