如何从SOAP响应中删除Mule标头

时间:2014-08-22 15:14:07

标签: soap jms mule mule-studio

我有一个要求,我需要公开SOAP Web服务..所以我有以下Mule流程: -

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>

<flow name="Flow1" doc:name="Flow1" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<jms:outbound-endpoint queue="NewQueue" connector-ref="Active_MQ" doc:name="JMS" exchange-pattern="request-response"/>
<logger message="Response2 :- #[message.payload]" level="INFO" doc:name="Logger"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
</flow>


<flow name="flow2" doc:name="flow2" >
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:NewQueue" doc:name="JMS" exchange-pattern="request-response" disableTemporaryReplyToDestinations="true" responseTimeout="90000"/>
<set-variable variableName="SOAPRequest" value="#[message.payload]" doc:name="Variable"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl">
<method-entry-point-resolver>
        <include-entry-point method="retrieveDataOperation"/>
        <include-entry-point method="insertDataOperation"/>
        <include-entry-point method="updateDataOperation"/>
        <include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
 </flow>

在这里,您可以看到请求从第一个流进入JMS队列,第二个流使用JMS inbound从JMS队列获取它,并且Web服务实现类处理它..现在服务正常工作没有任何问题。唯一的问题是它在响应中的SOAP中获取Mule Header,如下所示: -

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <mule:header xmlns:mule="http://www.muleumo.org/providers/soap/1.0">
         <mule:MULE_CORRELATION_ID>ID:ANIRBAN-PC-49483-1408719168461-1:1:10:1:1</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>
   </soap:Header>
   <soap:Body>
      <deleteDataResponse xmlns="http://services.test.com/schema/MainData/V1">
         <Response>Data not exists !!! Please provide correct ID</Response>
         <Id>0</Id>
         <Age>0</Age>
      </deleteDataResponse>
   </soap:Body>
</soap:Envelope>

现在请帮我从SOAP响应中删除Mule标题..我尝试了以下内容: - <cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData" enableMuleSoapHeaders="false" doc:name="SOAP"/>但没有用..它仍然显示Mule标题..请帮忙。

2 个答案:

答案 0 :(得分:0)

enableMuleSoapHeaders="false"问题得到解决之前,您可以通过以下方式解决临时解决方法:

  • 在HTTP入站端点和CXF服务之间添加;为了删除过度的SOAP标题,但XSL-Transformation
  • 使用delete-message-property删除MULE_*末尾的Flow1道具,紧跟mulexml:xml-to-object-transformer
  • 之后

答案 1 :(得分:0)

我还找到了将其添加到cxf:outInterceptors

的替代解决方案
 <cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP">
   <cxf:outInterceptors >
      <spring:bean id="outfault" class="com.test.services.schema.SOAPOptionalData.SOAPInterceptorOutboundHeaderRemover"/>
  </cxf:outInterceptors> 
</cxf:jaxws-service>

在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);
}

}
}

这也很好用