【问题标题】:XSLT in API connect version 10 Reserved instanceAPI 连接版本 10 中的 XSLT 预留实例
【发布时间】:2022-01-02 18:24:38
【问题描述】:

我是 API 连接开发的新手,尝试在 API 连接保留实例版本 10 中编写 XSLT。我有示例输入和 XSLT,但在执行相同操作时出错。

请求:下面是用作输入的示例 SOAP 请求。

    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
     <soap-env:Header/>
       <soap-env:Body>
        <n0:Z_V_PGIResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
            <RETURN>
                <item>
                    <PGIDAT>1</PGIDAT>
                    <MESSAGE>Delivery not found.</MESSAGE>
                </item>
                <item>
                    <PGIDAT>2</PGIDAT>
                    <MESSAGE>Delivery not found-2.</MESSAGE>
                </item>
            </RETURN>
        </n0:Z_V_PGIResponse>
    </soap-env:Body>
</soap-env:Envelope>

XSLT 代码:下面是我尝试在 v10 RI 中使用 APIM 和 APIGW 函数时使用的 XSLT

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:func="http://exslt.org/functions" xmlns:n0="urn:sap-com:document:sap:rfc:functions" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apimgw="http://www.ibm.com/apimanagement" extension-element-prefixes="dp func apim">
    <!-- Contains the APIM functions -->
    <xsl:import href="local:///isp/policy/apimgw.custom.xsl"/>
    <xsl:include href="store:///dp/apigw.custom.xsl"/>
    <xsl:template match="/">
        <!--<xsl:variable name="input" select="apim:payloadRead()"/>-->
        <xsl:variable name="currentPayload" select="apigw:read-payload('message')" />
        <RETURN>
            <xsl:for-each select="$currentPayload/soap-env:Envelope/soap-env:Body/n0:Z_V_PGIResponse/RETURN/item">
                <PGIDATE>
                    <xsl:value-of select="PGIDAT"/>
                </PGIDATE>
                <MESSAGE>
                    <xsl:value-of select="MESSAGE"/>
                </MESSAGE>
            </xsl:for-each>
        </RETURN>
</xsl:stylesheet>

错误-

"errName": "TransformError",

"errMsg": "执行样式表失败"

我浏览了几份 IBM 文档,但没有得到想要的输出,这有点令人困惑,因为一个与另一个相反。

【问题讨论】:

    标签: xslt ibm-datapower apiconnect apic


    【解决方案1】:

    如果该示例样式表是完整的,则您缺少模板的结束标记。

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:func="http://exslt.org/functions"
    xmlns:n0="urn:sap-com:document:sap:rfc:functions"
    xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:apimgw="http://www.ibm.com/apimanagement"
    extension-element-prefixes="dp func apim">
    <!-- Contains the APIM functions -->
    <xsl:import href="local:///isp/policy/apimgw.custom.xsl" />
    <xsl:include href="store:///dp/apigw.custom.xsl" />
    <xsl:template match="/">
        <!--<xsl:variable name="input" select="apim:payloadRead()"/> -->
        <xsl:variable name="currentPayload"
            select="apigw:read-payload('message')" />
        <RETURN>
            <xsl:for-each
                select="$currentPayload/soap-env:Envelope/soap-env:Body/n0:Z_V_PGIResponse/RETURN/item">
                <PGIDATE>
                    <xsl:value-of select="PGIDAT" />
                </PGIDATE>
                <MESSAGE>
                    <xsl:value-of select="MESSAGE" />
                </MESSAGE>
            </xsl:for-each>
         </RETURN>
       </xsl:template>
     </xsl:stylesheet>
    

    --HP

    【讨论】:

      猜你喜欢
      • 2014-07-09
      • 1970-01-01
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      • 2022-12-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多