I want to mock the error response of a target server, where the response is like:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<ErrorCode>2021</ErrorCode>
<ErrorMessage>Partner with given apikey not authorized to use this operation.</ErrorMessage>
</Error>
I am able to generate the error message except the first line of the message i.e.
Seems like Assign Message policy doesn’t support raw xml with xml initial tag, but you always have power of Javascript policies. See example below i.e working & proxy attached.
var errorResponseXml = '<?xml version="1.0" encoding="UTF-8"?><Error><ErrorCode>2021</ErrorCode><ErrorMessage>Partner with given apikey not authorized to use this operation.</ErrorMessage></Error>';
context.setVariable("errorResponseXml", errorResponseXml);