Spring Integration WS Outbound Gateway Error: InputStream не представляет действительное сообщение SOAP 1.1

Привет, я использую исходящий шлюз Spring Integration WS для вызова службы 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>

Это xsd, взятый из типов wsdl, которые я использую для создания объектов сопоставления из JAXB.

<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>

и returnndropoff.parceldroppost.createpreadvice.stubUrl - это URL-адрес конечной точки. Может ли кто-нибудь помочь, в чем проблема. Почему я получаю InputStream, не представляет действительное исключение сообщения SOAP 1.1 от WS Gateway.

Исключение 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

person Subhodeep Sen    schedule 01.03.2015    source источник
comment
Ваш returndropoff.parceldroppost.createpreadvice.stubUrl равен http://161.163.98.135:60719/ для address из WSDL? Вы тестировали целевую службу с помощью SOAP-UI? Похоже, ваша служба возвращает недопустимый Response. Пожалуйста, поделитесь дополнительными сведениями о StackTrace, чтобы убедиться, что проблема связана с ответом.   -  person Artem Bilan    schedule 01.03.2015
comment
Привет, Артем ... Большое спасибо за указатель ... Я изучил ответ от мыльного клиента, и он возвращал ответ с мылом версии 1.2, тогда как SaajSoapMessageFactory по умолчанию ожидает 1.1. Настроил то же самое для 1.2, и теперь он работает нормально.   -  person Subhodeep Sen    schedule 01.03.2015


Ответы (1)


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}"/>
person Artem Bilan    schedule 01.03.2015