camel cxf - 如何在电子邮件中发送soap请求响应

时间:2018-01-16 23:56:18

标签: java apache-camel cxf camel-cxf

Here is my spring configuration.

Spring.xml
-------------
<!-- Outgoing SOAP client endpoint -->
    <cxf:cxfEndpoint id="serviceEndpoint" address="${endpointAddress}"
        wsdlURL="${wsdlAddress}" endpointName="${portName}" serviceName="${serviceName}">

        <!-- The interceptors - needed to log the SOAP requests and responses -->
        <!-- They can be removed, when no logging is needed -->
        <cxf:inInterceptors>
            <ref bean="loggingInInterceptor" />
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="loggingOutInterceptor" />
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="loggingOutInterceptor" />
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="loggingInInterceptor" />
        </cxf:inFaultInterceptors>
<cxf:properties>
            <entry key="dataFormat" value="PAYLOAD" />          
        </cxf:properties>
    </cxf:cxfEndpoint>

    <http:conduit name="*.http-conduit">
        <http:tlsClientParameters disableCNCheck="${disableHostnameCheck}">
            <sec:keyManagers keyPassword="${keystorePassword}">
                <sec:keyStore type="JKS" password="${keystorePassword}"
                    file="${keystoreLocation}" />
            </sec:keyManagers>
            <sec:trustManagers>
                <sec:keyStore type="JKS" password="${truststorePassword}"
                    file="${truststoreLocation}" />
            </sec:trustManagers>
            <sec:cipherSuitesFilter>
                <!-- these filters ensure that a ciphersuite with export-suitable or 
                    null encryption is used, but exclude anonymous Diffie-Hellman key change 
                    as this is vulnerable to man-in-the-middle attacks -->
                <sec:include>.*_EXPORT_.*</sec:include>
                <sec:include>.*_EXPORT1024_.*</sec:include>
                <sec:include>.*_WITH_DES_.*</sec:include>
                <sec:include>.*_WITH_AES_.*</sec:include>
                <sec:include>.*_WITH_NULL_.*</sec:include>
                <sec:exclude>.*_DH_anon_.*</sec:exclude>
            </sec:cipherSuitesFilter>
        </http:tlsClientParameters>
        <http:client AutoRedirect="true" Connection="Keep-Alive"
            ReceiveTimeout="${connectionTimeout}" ConnectionTimeout="${connectionTimeout}" />
    </http:conduit>

Here is the Camel route configuration
-------------
<from ...
<to uri="cxf:bean:serviceEndpoint" />

This works well and we can have the soap request/response logged into the log file. Here soap request with soap header is generated by cxf.

我们是否有办法捕获soap请求和响应到camel Exchange?如果服务呼叫失败,我必须发送附有soap请求和响应的电子邮件。 尝试过使用本地线程,但它似乎没有预期的效果。

1 个答案:

答案 0 :(得分:0)

建议:

你在CXF拦截器中拥有它 - 看看它们。

我猜,您可以发送电子邮件。

org.apache.cxf.phase.AbstractPhaseInterceptor课程开始 - 不同阶段有很多不同的课程。

P.S。乍一看org.apache.cxf.binding.soap.saaj.SAAJInInterceptororg.apache.cxf.binding.soap.saaj.SAAJOutInterceptor可能是个好人......