【问题标题】:Replacing the deprecated https:outbound-endpoint with http:request in Mule在 Mule 中用 http:request 替换已弃用的 https:outbound-endpoint
【发布时间】:2015-10-14 05:47:02
【问题描述】:

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

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>

但是在使用新代码访问服务时,我收到一个 SOAP 错误作为响应。

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

这可能是什么原因?

仅供参考。我正在使用带有有效负载作为信封的 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>

【问题讨论】:

  • 使用旧传输时,该属性可能未映射为 HTTP 标头。您可以添加流程的代理客户端部分吗?整个事情会更有帮助,但这会很有帮助。
  • 添加了代理客户端部分。它被添加为消息属性 ​​ myservice/myEndpoint" />

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


【解决方案1】:

小小调整就神奇了!!

我在 http:request 之前设置了 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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-25
    • 2013-09-24
    • 1970-01-01
    相关资源
    最近更新 更多