【问题标题】:How to add Mule header using Interceptor?如何使用拦截器添加 Mule 标头?
【发布时间】:2016-06-20 12:15:01
【问题描述】:

嗨,我有一个肥皂请求

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <ns2:TrackRequest xmlns:ns4="namespace4" xmlns:ns3="namespace3" xmlns:ns2="namespace2" xmlns="namespace1">
        <Request>
            <RequestOption>BB</RequestOption>
        </Request>
        <ns2:InquiryNumber>AA</ns2:InquiryNumber>
    </ns2:TrackRequest>
</soap:Body>

我要这样

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
    <ns3:MYSecurity xmlns:ns3="namespace3">
        <ns3:UsernameToken>
            <ns3:Username>5</ns3:Username>
            <ns3:Password>N</ns3:Password>
        </ns3:UsernameToken>
        <ns3:ServiceAccessToken>
            <ns3:AccessLicenseNumber>AC</ns3:AccessLicenseNumber>
        </ns3:ServiceAccessToken>
    </ns3:MYSecurity>
</soap:Header>
<soap:Body>
    <soap:Body>
    <ns2:TrackRequest xmlns:ns4="namespac4" xmlns:ns3="namespace3" xmlns:ns2="namespace2" xmlns="namespace1">
        <Request>
            <RequestOption>BB</RequestOption>
        </Request>
        <ns2:InquiryNumber>AA</ns2:InquiryNumber>
    </ns2:TrackRequest>
</soap:Body>

我如何使用 mule SOAP CXF 组件来做到这一点?我们可以使用

public class SecurityHeaderInterceptor extends AbstractSoapInterceptor {

//java代码 }

class 文件使用 Java 来完成这项任务?如果可以,那是怎么回事?添加标题后需要输入。

【问题讨论】:

  • 您是否尝试过使用 log4j2.xml 日志记录配置? ,添加CXF的包即可。
  • 不行.. 怎么做?
  • 你用的是什么版本的mule?
  • 我正在使用 mule 3.6.1

标签: header namespaces mule cxf interceptor


【解决方案1】:

您可以扩展 org.apache.cxf.phase.AbstractPhaseInterceptor 然后修改 SOAPMessage 标头。

查看此链接以获取写入 SOAPMessage 标头的示例实现:https://www.classle.net/#!/classle/content-page/intercepting-soap-message/

【讨论】:

    【解决方案2】:

    我们可以使用 org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor 并覆盖 handleMessage(SoapMessage message)

    【讨论】:

      猜你喜欢
      • 2016-01-02
      • 2018-01-31
      • 1970-01-01
      • 2021-10-13
      • 2015-11-18
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多