在Mule中使用http:request替换已弃用的https:outbound-endpoint

时间:2015-10-14 05:47:03

标签: web-services soap mule cxf jax-ws

我使用以下配置在mule 3.2中点击基于SOAP的服务,该工作正常

<https:connector name="https" doc:name="HTTP\HTTPS"></https:connector>

<https:outbound-endpoint exchange-pattern="request-response" method="POST" 
            address="https://localhost:8080/CXF3Service/test" responseTimeout="15000" contentType="application/xml" 
            doc:name="HTTP Submit Request SOAP" connector-ref="https"> <message-properties-transformer 
            scope="outbound"> <add-message-property key="SOAPAction" value="https://myservice/myEndpoint" 
            /> </message-properties-transformer> </https:outbound-endpoint>

enter image description here

wsdl中的SOAP绑定看起来像,

<wsdl:operation name="sayHello">
<soap:operation soapAction="https://myservice/myEndpoint" style="document"/>
<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>

在迁移到Mule 3.6时,我将代码替换如下。这样做是为了用http:request

替换已弃用的https:outbound-endpoint
<http:request-config name="http" protocol="HTTPS"
        host="localhost" port="8080"
        doc:name="HTTP Request Configuration"/>

<http:request config-ref="http" path="CXF3Service/test" method="POST"
            doc:name="HTTP" responseTimeout="15000" >
            <http:request-builder>
                <http:header headerName="SOAPAction" value="https://myservice/myEndpoint" ></http:header>
            </http:request-builder>         
            <http:success-status-code-validator
                values="0..599" />
        </http:request>

enter image description here

但是在使用新代码访问服务时,我收到了SOAP Fault作为响应。

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Client</faultcode>
      <faultstring>Server did not recognize the value of HTTP Header SOAPAction: https://myservice/myEndpoint, "".</faultstring>
      <detail/>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

可能的原因是什么?

FYI。我使用的是一个cxf:proxy-client,有效负载为信封,两者都保持不变。

<cxf:proxy-client payload="envelope" doc:name="Proxy client">
    <cxf:inInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor">
            <spring:property name="prettyLogging" value="true" />
        </spring:bean>
    </cxf:inInterceptors>
    <cxf:outInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
            <spring:property name="prettyLogging" value="true" />
        </spring:bean>
    </cxf:outInterceptors>
    <cxf:outFaultInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
            <spring:property name="prettyLogging" value="true" />
        </spring:bean>
    </cxf:outFaultInterceptors>
</cxf:proxy-client>

1 个答案:

答案 0 :(得分:1)

小调整做了神奇!!

我在http:请求之前设置了SOAPAction,而不是在里面设置它。

<cxf:proxy-client payload="envelope" doc:name="Proxy client">
<cxf:inInterceptors>
    <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor">
        <spring:property name="prettyLogging" value="true" />
    </spring:bean>
</cxf:inInterceptors>
<cxf:outInterceptors>
    <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
        <spring:property name="prettyLogging" value="true" />
    </spring:bean>
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
    <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor">
        <spring:property name="prettyLogging" value="true" />
    </spring:bean>
</cxf:outFaultInterceptors>
</cxf:proxy-client>
  <message-properties-transformer>
      <add-message-property key="SOAPAction" value="https://myservice/myEndpoint"/>
    </message-properties-transformer>
    <http:request config-ref="http" path="CXF3Service/test" method="POST"
        doc:name="HTTP" responseTimeout="15000" >        
        <http:success-status-code-validator
            values="0..599" />
    </http:request>