3

I am attempting to receive JSON messages into BizTalk using the bLogical REST Start Kit for BizTalk (http://biztalkrest.codeplex.com/).

I am able to successfully receive a message, transform it, and return a response from my Orchestration, but when I transform the response back out through the BizTalkRESTResponseHandler, the HTTP Content-Type is being forced back to 'application/xml', even though I'm explicitly setting it to 'application/json'. The Content-Type is confirmed by tracing the Request and Response in Fiddler, as well as SoapUI.

The Accept: value on the Request is 'application/json'

Any ideas how I can trace further into the Wcf-Custom adapter stack to see where the Content-Type is being reset?

Brett
  • 1,127
  • 6
  • 11
  • As an update, I was not able to find a solution to this exact issue... yet. My current workaround has been to install a copy of BizTalk 2013 (yes, that's right, that's the "workaround") which supports the WCF-WebHttp transport. This binding exposes an "Outbound HTTP Headers" property, which allows you to explicitly set the Content-Type header value. – Brett Jun 05 '13 at 06:01

1 Answers1

0

You can solve this by adding a HttpResponseMessageProperty before returning the message in the IDispatchMessageInspector. You can either do this directly in the BizTalkRESTResponseHandler IDispatchMessageInspector or in a separate one.

To do it in the BizTalkRESTResponseHandler get the source and add the following 3 lines of code in the BeforeSendReply method just above the "reply = newReply" in the end.

HttpResponseMessageProperty prop = new HttpResponseMessageProperty();
newReply.Properties.Add(HttpResponseMessageProperty.Name, prop);
prop.Headers.Add("Content-Type", "application/json;charset=utf-8");

Now instead of getting:

enter image description here

You will get this:

enter image description here

magnus
  • 813
  • 2
  • 8
  • 15