I have a requirement within BizTalk to post data to a web service. This data needs to be in JSON format - once posted I am expecting something back in the same format but before I receive anything I keep hitting the same issue. I have spent around a day trying to figure it - I am pretty sure it must be something daft I am overlooking.
I have checked the endpoint using Postman and am having no issues when I post data directly.
The error I am receiving is the following;
xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'Orchestrations.STANDARD_OUT_WEBSERVICE(a064e1ce-3aec-fa09-9ceb-76b4447793a2)'. The service instance will remain suspended until administratively resumed or terminated. If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception. InstanceId: 3766050c-3a20-44e0-ae96-5137ab9ce270 Shape name: ShapeId: Exception thrown from: segment -1, progress -1 Inner exception: An error occurred while processing the message, refer to the details section for more information Message ID: {ABD1094C-826C-42D6-8776-AE28044B9BBC} Instance ID: {FC678BF5-BF84-4069-8385-00D0FD3547AE} Error Description: System.Net.WebException: (500) Internal Server Error at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result) Exception type: XlangSoapException Source: Microsoft.XLANGs.BizTalk.Engine Target Site: Void VerifyTransport(Microsoft.XLANGs.Core.Envelope, Int32, Microsoft.XLANGs.Core.Context) The following is a stack trace that identifies the location where the exception occured at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.VerifyTransport(Envelope env, Int32 operationId, Context ctx) at Microsoft.XLANGs.Core.Subscription.Receive(Segment s, Context ctx, Envelope& env, Boolean topOnly) at Microsoft.XLANGs.Core.PortBase.GetMessageId(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject location) at Orchestrations.STANDARD_OUT_WEBSERVICE.segment1(StopConditions stopOn) at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
The rough route of the message is as follows Orchestration 1 does some translations and then sends the message in XML format (using Xml Transmit) to Orchestration 2. Orchestration 2 receives the XML format (using Xml Receive) message and uses that to contruct a new JSON formatted message.
HeaderBuild = @"Content-Type:application\json" + "\n" + "UserName:biztalk-service";
Endpoint = "https://www.example.com/update";
ScaleWebserviceULOut(Microsoft.XLANGs.BaseTypes.Address) = Endpoint;
ScaleWebserviceULOut(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-WebHttp";
InboundMessageWithHeaders = InboundMessage;
InboundMessageWithHeaders(WCF.Action) = Endpoint;
InboundMessageWithHeaders(WCF.SecurityMode) = "Transport";
InboundMessageWithHeaders(WCF.HttpMethodAndUrl) = "POST";
InboundMessageWithHeaders(WCF.HttpHeaders) = HeaderBuild;
This message is then pushed to a dynamic send-receive port which uses a custom JSON encoder pipeline on the request and currently an XML Receive on the response (as currently I am not even getting to this point).
The message routes through to the port without issue and is definitely transforming to JSON. I have googled pretty hard on this one, I am not sure what I am doing wrong. Any ideas?
So as it turns out, the reason I was getting this error is...
HeaderBuild = @"Content-Type:application\json" + "\n" + "UserName:biztalk-service";
The content type for this was incorrect - changing this to a forward slash resolved the issue.
application/json
Thanks to ste-fu for pointing me towards fiddler