Layer7 API Management

 View Only
  • 1.  Extract attributes from request XML

    Posted May 14, 2020 01:34 AM
    Edited by Pavansai C May 14, 2020 01:37 AM
    Hi There,

    How to extract attributes from the below xml

    <?xml version="1.0" encoding="UTF-8"?>
    <p:justRequest   
        xmlns:p="http://abcd.com/xsd/api/okay/wait/v1/service"   
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://abcd.com/xsd/api/okay/wait/v1/service details.xsd">              <attribute1>value1</attribute1>
        <attribute2>value2</attribute2>
        <attribute3>value3</attribute3>
    </p:justRequest>

    have tried the following:
    ${request} must match XPath /justRequest/attribute1
    ${request} must match XPath /justRequest/@attribute1
    ${request} must match XPath /ns:values/ns:value/ns:attribute1/text()
    ${request} must match XPath /p:justRequest/attribute1

    no luck. please help!!!


  • 2.  RE: Extract attributes from request XML

    Broadcom Employee
    Posted May 14, 2020 02:12 AM
    This is not really attribute, just child element, the following xpath should work,
    /p:justRequest/attribute1


    Regards,
    Mark


  • 3.  RE: Extract attributes from request XML

    Posted May 14, 2020 02:22 AM
    Hi Mark,

    Have tried that already, it gives an error as follows:

    Can I use it as it is, it actually didn't work for me.


  • 4.  RE: Extract attributes from request XML

    Posted May 14, 2020 02:44 AM
    Also please help with using XSL Transformation, when can we use it?


  • 5.  RE: Extract attributes from request XML
    Best Answer

    Posted May 14, 2020 04:28 AM
      |   view attached
    // -- Double slash at the start


    ------------------------------
    Pre-Sales Consultant
    CA Southern Africa
    ------------------------------

    Attachment(s)

    xml
    sample_test.xml   2 KB 1 version


  • 6.  RE: Extract attributes from request XML

    Broadcom Employee
    Posted May 14, 2020 01:48 PM
    Whenever you have an XML message that needs to be transformed.

    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------



  • 7.  RE: Extract attributes from request XML

    Broadcom Employee
    Posted May 14, 2020 01:47 PM
    The correct way to handle this, in my opinion, is to add the namespace to the assertion. Click the Edit namespace button and add the prefix and url of the namespace that is missing:

    Also, using the Sample Message feature will automatically populate the namespaces, so you can just create a sample message in the interface to make life a bit easier. :)


    ------------------------------
    Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
    ------------------------------



  • 8.  RE: Extract attributes from request XML

    Broadcom Employee
    Posted May 14, 2020 08:03 PM
    Dear Pavansai C,
    You can either manually add namespace by clicking the "Edit Namespaces" button, or "Add" Sample Messages, and paste your sample xml, then it will add namespaces automatically.



    And then highlight the element node, it will populate the xpath automatically.

    Regards,
    Mark