Spring 集成 - 转换 soap 响应

Spring integration - transform soap response

我们有如下的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>

spring 集成配置在变压器下面有 tyhe,

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

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

我想获取值 - 2016-01-04,但出现错误。

有一个 xpath-expression-ref istead:

            <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/"/>