How to prevent BizTalk 2013/R2 WCF-WebHttp Rest Se

2019-08-13 00:31发布

问题:

I'm calling a vendor's REST service from a BizTalk orchestration using a WCF-WebHttp SendPort.

Even though I capture this System.Exception in an orchestration with a scope.exception, the SendPort remains suspended. Is there anyway to prevent the Susepend (WCF-CustomBehavior or Binding?) How do most BizTalk consumers of external REST services deal with this?

There are many different errors, some for security, some for data/configuration that might be returned with a 400 status, here is one example:

A message sent to adapter "WCF-WebHttp" on send port "spP44WebHttp" with URI "https://test.abc.com/api/v3" is suspended. Error details: System.Net.WebException: The remote server returned an unexpected response: (400) Bad Request. {"httpStatusCode":400,"httpMessage":"Bad Request","errorMessage":"Unable to handle shipment request","errors":[{"severity":"ERROR","message":"Customer-X does not support these accessorials: AIRPU","source":"SYSTEM"}],"supportReferenceId":"e0117674-9f83-4b42-b861-2e9b9f636323"}

When you have a Scope/Exception around any other two-way WCF send, such as WCF-SQL, it doesn't leave the SendPort suspended when you catch the error, does it?

Related: BizTalk Catch Http Response Code

Update 1: I found this TechNet Post which seems to be on target: https://social.technet.microsoft.com/wiki/contents/articles/33238.biztalk-server-2013-r2-handle-exceptions-from-rest-services-in-orchestration.aspx However, it states they could not catch the errors. I can catch the 400 errors, but what I don't like is the Suspended SendPort.

Update 2: I'm trying a custom behavior, where I was going to reset the status code in the BeforeSendReply. But using the debugger, I see the following methods run: Validate(), AddBindingParameters(), ApplyClientBehaviors(), BeforeSendRequest(), BUT - I never see the BeforeSendReply() run. So if BizTalk adapter doesn't like the 400 status, does that stop it from getting back into the Custom Behavior?