Whenever you pick up a new technology you discover stuff that other experts never talk about because it is obvious to them. As a newbie you can use a lot of time to work out the answers. This article tells a story about Azure Logic Apps content types and an obvious answer.
Setting the scene
I use a very simple Logic App pattern shown below.
A customer posts an order which triggers the logic app. Subsequently after placing the order on a service bus queue, BizTalk 2013R2 picks the order up with a SB-Messaging adapter for further processing. A previous post shows how I track the purchase order in OMS.
Our first production implementation uses a JSON order message and has been running for several months now without issue. Following on from this another Logic App shown below uses a similar pattern with an XML order message instead.
Setting the tracking property was a bit more tricky as shown below. XSLT does not find the Purchase Order number. Instead converting the XML to JSON and using JSON Path finds the purchase order number.
But this is not the issue that needs to be resolved. Testing this using Postman yields a successful result. On the contrary, Acceptance testing from the customer order application fails inside the Logic App.
Furthermore, I could reproduce this error using Postman if I changed the content type on the POST from application/xml to text/xml.
Wagner Silveira gave me a clue as to what as happening here. He said
Content-type indicates The MIME type of the request body. This header is important, because SOAP 1.1 and SOAP 1.2 accept very specific content-types. When calling a SOAP 1.1 service, the content-type must be text/xml, while for SOAP 1.2, the content-type is usually application/SOAP+xml.
This Logic App requires a content type of application/xml for some components. The solution is to convert the trigger body to xml using @xml() function. Orders with a content type of text/xml no longer fail if I make this change.
Last but not least the PO number tracked property can now be set like this
The lesson I learnt here is that Logic Apps are very fussy about content types. Casting content types to the correct one using functions may be necessary. Please read this Microsoft article for more detail.