It looks like you are pretty close, but you did not define the namespaces correctly when building the output schema.
Here is how you can define a namespaced element, and also a namespaced attribute (which is what xsi:schemaLocation is)
Then later on in your actions config you can define the default value for your attribute.
I'm not convinced you will need the xsi:schemaLocation - you could probably omit that.
Original Message:
Sent: Thu May 22, 2025 06:46 PM
From: Jimmy Perilla
Subject: Required namespaces in output XML message
Okay.
I've attached the API assembly, the XML message I'm getting with the current mapping, a screenshot of the flow, and the XML message with the structure the backend expects.
And the answer to your question: no, the backend doesn't work without that attribute.
Thanks so much for the help, and let me know if you need anything else.
------------------------------
Jimmy Perilla
Original Message:
Sent: Thu May 22, 2025 06:19 PM
From: Brendon Stephens
Subject: Required namespaces in output XML message
The screenshots are not very useful. You'll need to post your map code and the output xml if you want feedback on it. Is the xsi:schemaLocation definition a requirement? Will the backend work without it?
------------------------------
Brendon Stephens
Original Message:
Sent: Thu May 22, 2025 09:03 AM
From: Jimmy Perilla
Subject: Required namespaces in output XML message
In the map node I have tried the following ways:
- Extracting the value: xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance" xmlns="http://google.net/schema" xsi:schemaLocation="/www/services/xxx/ABC/webcontent/schemas/RQ123.xs using a GatewayScript, saving it in a context variable, and then calling it in the message property of the map node $(context.ctx.newMessage); and it has not worked for me.
- burning the value directly into the map node configuration ("http://www.w3.org/2001/XMLSchema-instance" xmlns="http://google.net/schema" xsi:schemaLocation="/www/services/xxx/ABC/webcontent/schemas/RQ123.xs"); and it doesn't work.
- declaring a variable with the desired value, and it didn't work either.
I've attached sample images.
Any other suggestions?
Thanks a lot.
------------------------------
Jimmy Perilla
Original Message:
Sent: Wed May 21, 2025 07:33 PM
From: Brendon Stephens
Subject: Required namespaces in output XML message
Can you post your map config and the output xml you are currently getting? Map action allows you to define the output namespace, so you shouldn't need to run it through a second xslt action to do this.
------------------------------
Brendon Stephens
Original Message:
Sent: Wed May 21, 2025 11:45 AM
From: Jimmy Perilla
Subject: Required namespaces in output XML message
Required namespaces in output XML message
Hello team,
I have a question.
I'm developing an API that receives a message in JSON format. Using a map node, I'm mapping and transforming JSON to XML (since my backend only receives the message in XML). However, the XML format expected by the backend is the following:
<?xml version="1.0" encoding="utf-8"?>
<message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://google.net/schema" xsi:schemaLocation="/www/services/xxx/ABC/webcontent/schemas/RQ123.xsd">
<version>1.0</version>
<header>
<operationCode>123</operationCode>
<origin>
<country>CO</country>
</origin>
<target>
<country>CO</country>
</target>
</header>
<key>
<grossAmount>
</grossAmount>
<documentsList>
<document>
</document>
<document>
</document>
</documentsList>
<serviceScript>SOAPXML123.XML</serviceScript>
</key>
</message>
and The JSON structure sent by the user is the following:
{
"grossAmount": {
"currency": {
"code": "CO",
"operationCode": "123"
},
"amount": 1
},
"maxDueDate": "2025-07-30",
"documents": [
"amount": 1
]
}
I need to know how I can include that namespace '<message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://google.net/schema" xsi:schemaLocation="/www/services/xxx/ABC/webcontent/schemas/RQ123.xsd">'
in the output of the message? Because in all my tests I can't include those values within the namespace since they are constants, they never change.
I'm using an XSL node after mapping with the map node, where I'm using the following code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsl xsi">
<xsl:output method="xml" indent="yes"/>
<!-- Copy everything as is -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Replace any root node named "message" regardless namespace -->
<xsl:template match="/*">
<message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://bac.net/schema"
xsi:schemaLocation="/www/services/bco/cus/webcontent/schemas/RQ09243.xsd">
<xsl:apply-templates select="@* | node()"/>
</message>
</xsl:template>
</xsl:stylesheet>
But I keep getting the XML response without the expected namespace.
Any suggestions? It would be very helpful.
Thanks
------------------------------
Jimmy Perilla
------------------------------