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)
<?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>
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.
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?
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>):
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