Layer7 API Management

  • 1.  Request.mainpart assignment

    Posted Aug 07, 2018 03:42 AM

    Dear Admin,

     

    I have a requirement to assign dynamic message body for a empty soap request basically null request body. When I set Apply XSLT Transformation assertion to the request message with desired xslt transformation, getting error like below.

     

    Request Headers: Content-Type text/xml

    Request Body: empty

    Transform Assertion: XSLT Transformation assertion (backend service is SOAP)

     

    Request: {}

     

    Response: 

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Body>
            <soapenv:Fault>
                <faultcode>soapenv:Server</faultcode>
                <faultstring>Policy Falsified</faultstring>
                <faultactor>https://server/rd/GetDesiredResults</faultactor>
                <detail>
                    <l7:policyResult status="Bad Request" xmlns:l7="http://www.layer7tech.com/ws/policy/fault"/>
                </detail>
            </soapenv:Fault>
        </soapenv:Body>
    </soapenv:Envelope>

     

    TimeSeverityCodeMessage
    20180807 17:18:30.809INFO5900

    Message not XML; cannot perform XSL transformation

     

    Intention is request is empty body, and backend routing service has fixed body. So when API is invoked client won't pass any body (basically null value in request.main part) however he suppose to get the desired response.



  • 2.  Re: Request.mainpart assignment

    Broadcom Employee
    Posted Aug 09, 2018 02:12 AM

    Dear Kirankumar_Konchada,

     

    Apply XSLT Transformation assertion requires any XML input. It doesn't accept empty value as XML and an error response is returned. (It is what you've seen.)
    If you'd like to pass through the empty request.mainpart to the backend, how about removing the Apply XSLT Transformation assertion from your policy?

     

    Sincerely,
    Seiji



  • 3.  Re: Request.mainpart assignment
    Best Answer

    Broadcom Employee
    Posted Oct 25, 2018 06:30 PM

    As the XSLT will not allow adding to an empty XML message you can create a new message context variable that can have the XML built in using some static and some dynamic values or dynamic values. The message context variable can then be assigned to the HTTP Routing assertion to be passed to the backend system.

    Sample variable (Note: dynamicValue2=<item2>1235</item2>):

    <foo>

    <item1>${dynamicValue1}</item1>

    ${dynamicValue2}

    </foo>

     

     

    Sincerely,

     

    Stephen Hughes

    CA Support



  • 4.  Re: Request.mainpart assignment

    Broadcom Employee
    Posted Nov 01, 2018 04:13 AM

    Hi

    Did the answer from Stephen Hughes answered your question? If it did please mark it as the right answer. When your question is not answered or you still have additional questions please let us know.

     

    With Kind Regards

    Conny