Greetings,
Is it possible to encode the xml tags of the body of a SOAP request in Talend using tXMLMap->tESBConsumer or another component prior to sending the request?
Talend returns errors for the following request with raw xml tags present:
<soap:Envelope>
<soap:Body>
<shipmentEnvelope>
<shipment>
<details>
<shipmentCurrencyCode>USD</shipmentCurrencyCode>
<shipmentType>AIATA</shipmentType>
<measurementType>MET</measurementType>
<exportCountry>US</exportCountry>
<importCountry>ES</importCountry>
</details>
</shipment></shipmentEnvelope></soap:Body></soap:Envelope>
I tested in a SOAP client and received a similar error. However, when encoding the XML tags of the SOAP:Body i get the desired result:
<soap:Envelope>
<soap:Body>
<shipmentEnvelope>
<shipment>
<details>
<shipmentCurrencyCode>USD</shipmentCurrencyCode>
<shipmentType>AIATA</shipmentType>
<measurementType>MET</measurementType>
<exportCountry>US</exportCountry>
<importCountry>ES</importCountry>
</details>
</shipment>
</shipment></shipmentEnvelope></soap:Body></soap:Envelope>
Is it possible to encode the XML tags for the body of the payload and not the header? If so-what approach/components should I use to accomplish this?
This is not the way how soap works. The payload will be send typically with a name space in it. This way you do not have to bother with encodings! What about creating your own shipment name space - lets call it ship.
Now you create your payload:
<ship:shipmentEnvelope xmlns:ship="http://mycompany/">
... now you can use the name space for all further tags (not necessary to repeat the declaration).
Thanks for the reply. I actually removed the namespaces from the example; the envelope does have a namespace in both instances. Sorry for the confusion.
For some reason, however, I am unable to send the raw XML. I can only get the payload to successfully send when replacing the xml greater than/less than tags with > and <. The soap:header doesn't appear to have an issue with the raw XML, but anything within the soap:body in raw XML format is giving me issues. Is there any way to programatically replace the xml tags in just the soap:body? Can this be done with a component or would I need to write custom code in order to do this?
The document is an w3c document. It would be much easier to convert into a String (before you ask, I didn't have done this, Google is you friend 😉 and perform with it the replacements.