如何在soap请求和响应中发送mule头文件

时间:2013-03-15 19:33:15

标签: mule

我的请求响应http endpoint定义如下:

<http:inbound-endpoint address="${mvi.service.address}" exchange-pattern="request-response">
   <cxf:proxy-service wsdlLocation="classpath:mvi.wsdl" namespace="http://pennmutual.com/services/mvi" service="MVIService" />
</http:inbound-endpoint>

它发送回客户端的响应包含如下所示的mule标题:

 <soap:Header>
  <mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
     <mule:MULE_CORRELATION_ID>4784545a-4fad-44ac-171e-1bc150ccdcb2</mule:MULE_CORRELATION_ID>
     <mule:MULE_CORRELATION_GROUP_SIZE>-1</mule:MULE_CORRELATION_GROUP_SIZE>
     <mule:MULE_CORRELATION_SEQUENCE>-1</mule:MULE_CORRELATION_SEQUENCE>
  </mule:header>

   

如何摆脱<mule:header>元素?

2 个答案:

答案 0 :(得分:3)

添加:

enableMuleSoapHeaders="false"

cxf:proxy-service上。还添加了一个全局CXF配置元素:

<cxf:configuration enableMuleSoapHeaders="false"/>

答案 1 :(得分:0)

有一种替代方法可以使用cxf:outInterceptors和java类删除Mule标头,如下所示: -

<http:inbound-endpoint address="${mvi.service.address}" exchange-pattern="request-response"/>
<cxf:proxy-service wsdlLocation="classpath:mvi.wsdl" namespace="http://pennmutual.com/services/mvi" service="MVIService" >
<cxf:outInterceptors >
  <spring:bean id="outfault" class="com.SOAPInterceptorOutboundHeaderRemover"/>
</cxf:outInterceptors> 
</cxf:proxy-service>

在您的SOAPInterceptorOutboundHeaderRemover java类中: -

public class SOAPInterceptorOutboundHeaderRemover extends AbstractSoapInterceptor {

public SOAPInterceptorOutboundHeaderRemover() {
super(Phase.PRE_PROTOCOL);
}

@Override
public void handleMessage(SoapMessage arg0) throws Fault {
List<Header> headerList = arg0.getHeaders();
Header muleHeader = null;
boolean isMuleHeader = false;
for (Header header : headerList) {
ElementNSImpl element = (ElementNSImpl) header.getObject();
if ("mule:header".equals(element.getNodeName())) {
isMuleHeader = true;
muleHeader = header;
}
}
if (isMuleHeader) {
arg0.getHeaders().remove(muleHeader);
}

}
}

这个cxf:outInterceptors java类来自响应的Mule头并且工作正常