Mule MtoM传输出站验证错误

时间:2013-03-19 16:00:50

标签: soap mule mtom

将MtoM添加到Jboss 7中运行的业务服务后,我们发现通过Mule传递soap请求现在会导致错误: -

<faultstring>An exception occurred while invoking message processor "DefaultMessageProcessorChain '(inner iterating chain) of OutboundEndpoint 'http://127.0.0.1:8280/communication' request chain' 
[ 
  org.mule.endpoint.outbound.OutboundEventTimeoutMessageProcessor, 
  org.mule.endpoint.outbound.OutboundSessionHandlerMessageProcessor, 
  org.mule.endpoint.outbound.OutboundEndpointPropertyMessageProcessor, 
  org.mule.endpoint.outbound.OutboundResponsePropertiesMessageProcessor
]" with transaction "Transaction{factory=null, action=NEVER, timeout=0}".. Message payload is of type: PostMethod</faultstring>

这似乎是由在服务响应中的有效负载在传回SOAPUI之前验证时发生的验证错误引起的。检查Mule日志文件,将记录:

Caused by: org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader.
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:222)
    at ... 80 more
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '-' (code 45) in prolog; expected '<'
 at [row,col {unknown-source}]: [1,1]
    at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:644)
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2003)
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1100)
    at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1123)
    at org.mule.module.xml.stax.DelegateXMLStreamReader.nextTag(DelegateXMLStreamReader.java:242)
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)
    ... 90 more

错误似乎发生是因为MULE尝试将soap响应解析为validatingStreamReader中的XML,而实际上SOAP信封在标题中包含以下文本:

[------=_Part_22_1884954755.1363694621407 Content-Type:application/xop+xml;charset=utf-8;type="text/xml"

<SOAP-ENV:Envelope.....

因此,验证失败,因为MtoM标记使SOAP数据包格式错误。

下面是我的mule配置

<!-- Primary Choice router is used to forward requests to the wsdl proxy 
        and SOAPflow this should be the only endpoint that is exposed to the public 
        domain. -->
    <flow name="SOAInboundRouter">
        <!-- public inbound listener -->
        <inbound-endpoint address="${web.inboundAddress}"
            exchange-pattern="request-response" />

        <!-- Outbound filter for routing requests -->
        <choice>
            <when>
                <regex-filter pattern="soap" />
                <outbound-endpoint
                    address="${soa.inboundAddress}#[header:inbound:http.request]"
                    exchange-pattern="request-response" />
            </when>
        </choice>

    </flow>

    <!-- Flow used for SOAP request processing, this implements a callback to 
        check the SOAP header for the correct username token for WS-Security request 
        are passed to this flow by the Flow SOAInboundRouter. This endpoint is not 
        for use in the public domain. -->

    <flow name="SoapFlow">
        <!-- http listener for SOAP requests -->
        <inbound-endpoint address="${soa.inboundAddress}"
            exchange-pattern="request-response">
            <cxf:proxy-service service="" namespace="">
                <!-- WS-Security intercetor applied to the inbound request -->
                <cxf:inInterceptors>
                    <spring:ref bean="cxfSecurityInterceptor" />
                </cxf:inInterceptors>

            </cxf:proxy-service>
        </inbound-endpoint>

        <!--Success on authentication request is passed to outbound router this 
            is the actual service -->
        <outbound-endpoint
            address="${soa.outboundAddress}#[header:inbound:http.request]"
            exchange-pattern="request-response">
            <cxf:proxy-client />
        </outbound-endpoint>

    </flow>

    <!-- application configuration -->
    <spring:bean id="cxfSecurityInterceptor"
        class="uk.co.weatherbys.security.esb.cxf.CXFSecurityInterceptor"
        scope="prototype">
        <spring:constructor-arg value="${mule.userfile}" />
        <spring:property name="wServiceHeaderDelegate" ref="wServiceHeaderDelegate" />
        <spring:property name="cxfWsSecurityDelegate" ref="cXfWsSecurityDelegate" />
    </spring:bean>

    <spring:bean id="wServiceHeaderDelegate"
        class="uk.co.weatherbys.security.esb.cxf.WServiceHeaderDelegate">
    </spring:bean>

    <spring:bean id="cXfWsSecurityDelegate"
        class="uk.co.weatherbys.security.esb.cxf.CxfWsSecurityDelegate">
    </spring:bean>

我到处检查过一个解决方案,但找不到一个。有没有人有什么建议? 我可以以某种方式关闭出站验证吗?我是否需要配置变换器来处理这种非标准头信息?我需要一个新流程吗?

由于

1 个答案:

答案 0 :(得分:1)

我之前看到过类似的事情,因为CXF代理正在改变多部分/相关的内容类型;类型= “应​​用/ XOP + xml” 的; .....对回复的“文本/简单”。

您可以记录Content-Type并尝试手动设置或复制Content-Type,类似于:

<code>
    <message-properties-transformer>
    <add-message-property key="Content-Type" value="#[header:Content-Type]" />
    </message-properties-transformer> 
</code>

参见 http://forums.mulesoft.org/message.jspa?messageID=9152 并向下滚动或搜索“wstx”