即使设置了SaajSoapMessageFactory soap版本,InputStream也不表示有效的SOAP 1.2消息

时间:2018-10-12 12:36:10

标签: java web-services soap spring-ws saaj

我遇到以下错误:

  

org.springframework.ws.soap.SoapMessageCreationException:无法   从InputStream创建消息:InputStream不代表   有效的SOAP 1.2消息;嵌套异常为   javax.xml.soap.SOAPException:InputStream不代表有效的   SOAP 1.2消息

我尝试设置messageFactorysoap version to 1.2,但仍然得到相同的error

下面是我的wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://i3l.com/finnair/process/bpm/wsdl/BPMCheckDBConnectivityPWS" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://i3l.com/finnair/process/bpm/wsdl/BPMCheckDBConnectivityPWS" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:types1="http://i3l.com/finnair/process/bpm/xsd/BPMCheckDBConnectivityPXS" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<plnk:partnerLinkType xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" name="BPMCheckDBConnectivity">
   <plnk:role name="Process" portType="tns:BPMCheckDBConnectivityPWSPT"/>
</plnk:partnerLinkType>
  <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:import namespace="http://i3l.com/finnair/process/bpm/xsd/BPMCheckDBConnectivityPXS" schemaLocation="BPMCheckDBConnectivityPXS.xsd"/>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="startCheckDBConnectivityResponse">
    <wsdl:part name="startCheckDBConnectivityResponse" element="types1:checkDBConnetivityResp">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="startCheckDBConnectivityRequest">
    <wsdl:part name="startCheckDBConnectivityRequest" element="types1:checkDBConnetivityReq">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="BPMCheckDBConnectivityPWSPT">
    <wsdl:operation name="startCheckDBConnectivity">
      <wsdl:input message="tns:startCheckDBConnectivityRequest">
    </wsdl:input>
      <wsdl:output message="tns:startCheckDBConnectivityResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="BPMCheckDBConnectivityPWSPTSOAP12Binding" type="tns:BPMCheckDBConnectivityPWSPT">
    <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="startCheckDBConnectivity">
    <soap12:operation soapAction="" style="document"/>
      <wsdl:input>
    <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
    <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="BPMCheckDBConnectivityPWSPTBinding" type="tns:BPMCheckDBConnectivityPWSPT">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="startCheckDBConnectivity">
    <soap:operation soapAction="" style="document"/>
      <wsdl:input>
    <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
    <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="BPMCheckDBConnectivityPWSPT">
    <wsdl:port name="BPMCheckDBConnectivityPWSPTPort" binding="tns:BPMCheckDBConnectivityPWSPTBinding">
    <soap:address location="http://bpmext.finnair.fi:9090/active-bpel/services/soap12/BPMCheckDBConnectivityPWSPT"/>
    </wsdl:port>
    <wsdl:port name="BPMCheckDBConnectivityPWSPTSOAP12Port" binding="tns:BPMCheckDBConnectivityPWSPTSOAP12Binding">
    <soap12:address location="http://bpmext.finnair.fi:9090/active-bpel/services/soap12/BPMCheckDBConnectivityPWSPT"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

这是我的Spring ws客户:

public CheckDBConnetivityRespType startCheckDBConnectivity(CheckDBConnetivityReqType checkDBConnetivityReqType) {
        CheckDBConnetivityRespType response = (CheckDBConnetivityRespType) getWebServiceTemplate()
                .marshalSendAndReceive(targetUri, checkDBConnetivityReqType);
        return response;
    }

这是我的ApplicationClientConfig班:

@Configuration
public class ClientAppConfig {


    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setContextPath("com.i3l.finnair.process.bpm.xsd.bpmcheckdbconnectivitypxs");
        return marshaller;
    }

    @Bean
    public SaajSoapMessageFactory messageFactory() {
        SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory();
        messageFactory.setSoapVersion(SoapVersion.SOAP_12);
        return messageFactory;
    }

    @Bean
    public BPMCheckDBConnectivityClient bpmCheckDBConnectivityClient(Jaxb2Marshaller marshaller) {
        BPMCheckDBConnectivityClient client = new BPMCheckDBConnectivityClient();       
        //client.setDefaultUri("");
        client.setMessageFactory(messageFactory());
        marshaller.setMtomEnabled(true);
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        client.setMessageSender(httpComponentsMessageSender());
        return client;
    }

    @Bean
      public HttpComponentsMessageSender httpComponentsMessageSender() {
        HttpComponentsMessageSender httpComponentsMessageSender = new HttpComponentsMessageSender();
        // set the basic authorization credentials
        httpComponentsMessageSender.setCredentials(usernamePasswordCredentials());

        return httpComponentsMessageSender;
      }

      @Bean
      public UsernamePasswordCredentials usernamePasswordCredentials() {
        // pass the user name and password to be used
        return new UsernamePasswordCredentials(username, password);
      }
}

0 个答案:

没有答案