3

Custom Policy with xslt

 11 months ago
source link: https://chrisphillips-cminion.github.io/apiconnect/2023/05/23/xsltpolicy.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Custom Policy with xslt

Custom Policy with xslt

May 23, 2023 • Category APIConnect by Chris Phillips

Recently I was asked to provide a sample custom policy for APIC that contained an XSLT.

The policy below is a very basic sample. The XSLT can be updated and parameters added.

policy: 1.0.0
info:
  title: SampleXLST Custom Policy
  name: sample-xslt-udp
  version: 1.0.0
  description: Example policy with an xslt policy
  contact:
    name: Chris Phillips
    url: 'https://chrisphillips-cminion.github.io/'
    email: [email protected]
attach:
  - rest
  - soap
gateways:
  - datapower-api-gateway
assembly:
  execute:
    - xslt:
        version: 2.1.0
        title: xslt
        input: false
        serialize-output: true
        source: |2-
              <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
                <xsl:template match="/">
                  <Hello>World!</Hello>
                </xsl:template>
              </xsl:stylesheet>

Once this policy is created you need to zip up the yaml file and load it into APIC. This is loaded in via the UI by going to the Catalog(or space)->Settings->Gateway Serviecs->View Policies

image

Click on Upload

Drag and Drop the zip file into the first field.

image

The policy will now be listed in the Policy List.

image

If you have added this to the sandbox catalog when you go to drafts you will see the custom policy on the canvas.

image

A video on how to do this with a different policy will be published soon.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK