-->

How can I return HTTP-400 from a BizTalk Rest serv

2020-04-17 05:37发布

问题:

I am using BizTalk 2013 R2 and I have a RESTFUL service.

How can I return a HTTP-400 response to a client?

回答1:

Set WCF.OutboundHttpStatusCode property in message assignment shape:

MyResponseMessage(WCF.OutboundHttpStatusCode) = "400";


回答2:

Oleg's answer will work if you have an Orchestration

If you want a messaging only solution you will have to have a Pipeline Component set the same context property.

For this we tend to use the BizTalk Business Rules Engine Pipeline Framework

In your Business Rule policy, use the SetCustomContextProperty from the BREPipelineFramework.SampleInstructions.ContextInstructions in your Actions and set the context name of OutboundHttpStatusCode and a namespace of http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties and set the value to 400

The picture below show what it looks like, but with a 404

Disclosure: This framework was written by someone I have worked with.