代码之家  ›  专栏  ›  技术社区  ›  Kris Swat

spring集成-转换soap响应

  •  0
  • Kris Swat  · 技术社区  · 6 年前

    我们有如下的有效载荷,希望提取

     <?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集成配置在transformer下面,

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

    我需要指定名称空间吗?如果需要,如何指定?

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

    1 回复  |  直到 6 年前
        1
  •  1
  •   Artem Bilan    6 年前

    有一个 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/"/>