Spring集成 - 转换肥皂响应

时间:2018-06-08 16:03:55

标签: jms spring-integration

我们有Payload如下,并想提取值

 <?xml version="1.0" encoding="UTF-8"?><ns2:DCResponse xmlns:ns2="http://bgs.beienst.kl/tm/">
    <ns2:sdate>2016-01-04</ns2:sdate></ns2:DCResponse>

弹簧集成配置在变压器下方,

<int-xml:xpath-transformer input-channel="tcSoapChannel" output-channel= "tcOutputChannel"  evaluation-type="NODE_RESULT" 
      xpath-expression="//DCResponse/sdate" />

我是否需要指定命名空间?若是,如何?

我想获得价值 - 2016-01-04,但收到错误。

1 个答案:

答案 0 :(得分:1)

有一个xpath-expression-ref isntead:

            <xsd:attribute name="xpath-expression-ref" type="xsd:string">
                    <xsd:annotation>
                        <xsd:documentation>
Reference to the XPathExpression instance to be evaluated against the input Message's payload.
Either this or 'xpath-expression' must be provided, but not both.
                        </xsd:documentation>
                        <xsd:appinfo>
                            <tool:annotation kind="ref">
                                <tool:expected-type type="org.springframework.xml.xpath.XPathExpression"/>
                            </tool:annotation>
                        </xsd:appinfo>
                    </xsd:annotation>
                </xsd:attribute>

因此,您可以配置像:

这样的bean
<int-xml:xpath-expression id="xpathExpression" expression="//DCResponse/sdate" 
                          ns-prefix="ns2" ns-uri="http://bgs.beienst.kl/tm/"/>