将mule变量数据或类似mule属性的有效负载复制到springbean属性



我有一个mule流,其中有一个变量,有效载荷复制到该变量,如下所示:

<set-variable variableName="originalPayload" value="#[payload]" doc:name="Variable" doc:description="Variable having copy of original payload present in soap request."/>

之后有一个拦截器来验证soap消息的头,如果验证失败,那么我需要拦截器中的上述变量的数据来准备自定义故障消息。下面是我对Soap Proxy的配置:

<cxf:proxy-service port="XXX" namespace="XXX" service="XXX" payload="body" wsdlLocation="XXXX" doc:name="SOAP" doc:description="Soap proxy intercept soap request and apply header validation. Authentication and custom header will be validated for presence, content, and structure.">
    <cxf:inInterceptors>
        <spring:bean id="XXXX" parent="XXXX">
            <spring:property name="sourceApplication" value="${sourceApplication}"/>
            <spring:property name="originalMessage" value="#[originalPayload]"/>
        </spring:bean>
    </cxf:inInterceptors>
</cxf:proxy-service>

在上面,我需要springbean的originalMessage属性中originalPayload变量的值。如果我可以直接复制#[payload],它也会起作用。spring属性中的上述表达式无效,因此它不起作用。

请建议如何做到这一点。

实现Callable可能是一种选择,但我不想更改已经编写的代码,除非上面没有解决方案。

我试图寻找解决方案,但没有找到任何东西。

谢谢Harish Kumar

解决方案的问题是在配置时设置spring属性,而#[payload]表达式只能在运行时解决。

然而,在拦截器中,您可以通过以下操作从CXF消息中检索原始有效载荷:

MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT);
Collection<Attachment> a = event.getMessage().getInvocationProperty("originalPayload");

您可以将此拦截器作为的示例

最新更新