We have discovered that if a SOAP fault is sent to a pipeline using the JSON Encoder the following error occurs;
A response message sent to adapter “WCF-WebHttp” on receive port “OrderAPI” with URI “/order/v2/Service1.svc” is suspended.
Error details: There was a failure executing the response(send) pipeline: “Pipelines.CustomerDetails.Snd_JSON, Pipelines.CustomerDetails, Version=22.214.171.124, Culture=neutral, PublicKeyToken=1bdcdd64c42ec63e” Source: “JSON encoder” Receive Port: “OrderAPI” URI: “/order/v2/Service1.svc” Reason: Object reference not set to an instance of an object.
We can reproduce the same error if we submit the SOAP fault to any send port that uses the JSON Encoder. We believe that this is an inherent problem in the JSON encoder i.e. It cannot resolve a SOAP fault. This makes it very difficult to handle exceptions and return a message to clients that want to consume a REST/JSON service hosted in BizTalk Server. We had intended to “sanitize” all faults in a custom behaviour but this runs after the pipeline component is executed.
We added an orchestration between the receive and downstream endpoints. We also added exception handling in the orchestration to raise a fault message. This time the JSON encoder does process the fault message successfully.
Thus one workaround for this issue is to introduce an orchestration into the messaging only solution. Can anyone else think of a way that we can maintain a messaging only solution that uses BizTalk 2013 R2 JSON encoder by removing the SOAP fault envelope prior to the message going through the inbound pipeline?