0

我是 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": "转换错误",

"errMsg": "未能执行样式表"

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

4

1 回答 1

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>

- 生命值

于 2022-01-25T08:01:23.797 回答