Handling SOAP/XML payloads in endpoint

Hello,
I am having some trouble with setting up an endpoint which should receives data from a SOAP integration. The service is configured as a POST, and the incoming request has Content-Type: application/xml;charset=utf-8.
When the request comes in with this content type, bodyPayload is completely empty. However, if I send the exact same XML with Content-Type: text/plain, I’m able to access the data in bodyPayload just fine.

I’ve tried parsing rawBodyData.toString() in the Body Parser function as a workaround, but even then it seems like rawBodyData is null or empty when using application/xml.

Has anyone successfully handled application/xml payloads in a service endpoint? Any tips would be greatly appreciated :folded_hands:

2 Likes

Hi!

I seems like sending XML to an endpoint in Appfarm only works when the header “content-type” is set to “text/plain” for the SOAP cases… Using content-type “application/xml” removed the whole body.

So, sending in <OrderID>123</OrderID> to an Endpoint, with header content-type = “text/plain” allows you to have the following body parser (and then use mapping to map orderId to a data source property):

const parser = new DOMParser()
const xmlDoc = parser.parseFromString(rawBodyData, 'text/xml')

const OrderResult = xmlDoc.getElementsByTagName('OrderId')

return {
		OrderId: OrderResult[0].textContent
	}

However, I would guess you are not in control of what that header (content-type) is set to? I’ll register a challenge internally for this.

Yes, Im not able to change what the content-type is set to :frowning:
Hopefully this is something you are able to fix qucik, as I would need it as soon as possible: :sweat_smile: :crossed_fingers:

Hi,

This one is now patched and rolled out. XML content-types may now be sent to Appfarm endpoints!

2 Likes