mule – Anypoint Studio problem with JSON into XML transformation
I am trying to convert JSON response into XML and then call SOAP API with payload. I managed to get JSON response without any trouble, but I am unable to convert it to XML. the problem is data has to be in format:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumberToDollars xmlns="http://www.dataaccess.com/webservicesserver/">
<dNum>47.92</dNum>
</NumberToDollars>
</soap:Body>
</soap:Envelope>
but when I use this as example for Transform Messages
module it creates:
%dw 2.0
output application/xml
ns ns00 http://schemas.xmlsoap.org/soap/envelope/
ns ns01 http://www.dataaccess.com/webservicesserver/
---
{
ns00#Envelope: {
ns00#Body: {
ns01#NumberToDollars: {
ns01#dNum: payload.decimal
}
}
}
}
and when I use a Logger
to view the output it is:
<?xml version='1.0' encoding='UTF-8'?>
<ns00:Envelope xmlns:ns00="http://schemas.xmlsoap.org/soap/envelope/">
<ns00:Body>
<ns01:NumberToDollars xmlns:ns01="http://www.dataaccess.com/webservicesserver/">
<ns01:dNum>47.92</ns01:dNum>
</ns01:NumberToDollars>
</ns00:Body>
</ns00:Envelope>
I know I can change it manually and I managed to get it to look like this:
%dw 2.0
output application/xml
ns soap http://schemas.xmlsoap.org/soap/envelope/
ns ns01 http://www.dataaccess.com/webservicesserver/
---
{
soap#Envelope: {
soap#Body: {
NumberToDollars: {
dNum: payload.decimal
}
}
}
}
output:
<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<NumberToDollars>
<dNum>47.92</dNum>
</NumberToDollars>
</soap:Body>
</soap:Envelope>
But I have no idea how to get NumberToDollarsbe without namespace and at the same time to have xmlns link (how can I get rid of ns00 and at the same time keeping the link).
I checked all there was about it in Mule Documentation and found nothing please, please help.
Read more here: Source link