I need integrate with a system with this WSDL: wsdl
In Studio, I use "Web Service Consumer". The problem is in the body. IN transform I create the payload, but i only get it to work if i hardcode it; I can't make the string dynamic
This script works but it uses fixed literal strings:
%dw 2.0
output application/xml
ns ns0 http://test.es/IC/SERVICE/
---
{
ns0#wsImprXML: {
ns0#DataXML: "
<root>
<exp>
<bult>
<ci>965</ci>
<nif>123</nif>
<ccc>36020</ccc>
<service>31</service>
<product>2</product>
<total>1</total>
<price>10,6</price>
</bult>
</exp>
</root>",
ns0#OptionsXML: "<wsOptionsXML>
<VersionDataXML>1.0.0</VersionDataXML>
<VersionOptionsXML>1.0.0</VersionOptionsXML>
<VersionResponseXML>1.1.0</VersionResponseXML>
<VersionErrorXML>3.2.0</VersionErrorXML>
</wsOptionsXML>"
}
}
How can I create the string inside the body of the xml? This string must be dynamic (filling it with values that I have stored in variables)?
You should not use literal XML. You can easily generate XML dynamically from anything that DataWeave considers an object. I'll give an example with DataWeave variables, that you can replace by Mule variables (vars.myVar
). Using the write() function converts an object into a string as your WSDL requires. You can pass the transformed text, or convert it in place, as I'm showing below.
%dw 2.0
output application/xml
ns ns0 http://test.es/IC/SERVICE/
var someText=write(
{
root: {
exp: {
bult: {
ci: 965,
nif: 123,
ccc: 36020,
service: 31,
product: 2,
total: 1,
price: 10.6
}
}
}
}, "application/xml")
var someObject= {
wsOptionsXML: {
VersionDataXML: "1.0.0",
VersionOptionsXML: "1.0.0",
VersionResponseXML: "1.1.0",
VersionErrorXML:"1.2.0"
}
}
---
{
ns0#wsImprXML: {
ns0#DataXML: someText,
ns0#OptionsXML: write(someObject,"application/xml")
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments