在 WCF-WebHttp 传输中抑制出站消息中的动词
Suppressing verbs in Outbound Message in WCF-WebHttp Transport
我在这里练习教程 - Invoking REST Interface using BizTalk Server
在该页面中,步骤 3(e) 指示提供 GET 作为要在 属性 - Suppress Body for Verbs
的出站消息中抑制的动词。给出的解释对我来说不清楚。
作为实验,我删除了 GET 动词并删除了一个输入文件。该应用程序因以下错误而暂停:
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
Server stack trace:
at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult..ctor(HttpWebRequest httpWebRequest, HttpOutput httpOutput, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.BeginGetOutputStream(AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.SendWithoutChannelBindingToken()
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.Send()
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult..ctor(HttpOutput httpOutput, HttpResponseMessage httpResponseMessage, Boolean suppressEntityBody, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartSend(Boolean completedSynchronously)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin()
at System.ServiceModel.Channels.ServiceChannel.BeginCall(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, TimeSpan timeout, AsyncCallback callback, Object asyncState)
at System.ServiceModel.Channels.ServiceChannel.BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.ServiceChannel.BeginRequest(Message message, AsyncCallback callback, Object state)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.Channels.IRequestChannel.BeginRequest(Message message, AsyncCallback callback, Object state)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendRequestMessage(IBaseMessage bizTalkMessage, IRequestChannel channel)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendMessage(IBaseMessage bizTalkMessage)
MessageId: {9FA7042A-0391-4AAF-946F-FE9C5516ABFD}
InstanceID: {4C29E43D-278A-4615-8A30-4ED1B1CBC2AD}
为什么需要这样做?当我不抑制它时究竟会发生什么?
默认情况下,BizTalk 在发送时会发送消息负载(内容正文)。
当您尝试使用 RESTful 服务并想要执行 GET 时,您通常不想发送消息负载,您也只是从 URL 中获取内容,因此你想禁止发送内容主体。
查看相关问题Cannot send a content-body with this verb-type
如果您发送带有 GET 请求的内容主体会发生什么变化。
一些代理可能会在请求上出现错误或错误,或者终端服务器可能会抛出异常,因为它不期望内容主体。
您需要隐藏 body,而不是动词。这里有一个已构建并可用的自定义管道组件:https://code.msdn.microsoft.com/biztalk-2010-r2-rest-wcf-fdb2e91f 可以为您完成此操作。
我在这里练习教程 - Invoking REST Interface using BizTalk Server
在该页面中,步骤 3(e) 指示提供 GET 作为要在 属性 - Suppress Body for Verbs
的出站消息中抑制的动词。给出的解释对我来说不清楚。
作为实验,我删除了 GET 动词并删除了一个输入文件。该应用程序因以下错误而暂停:
System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type.
Server stack trace:
at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult..ctor(HttpWebRequest httpWebRequest, HttpOutput httpOutput, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.BeginGetOutputStream(AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.SendWithoutChannelBindingToken()
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult.Send()
at System.ServiceModel.Channels.HttpOutput.SendAsyncResult..ctor(HttpOutput httpOutput, HttpResponseMessage httpResponseMessage, Boolean suppressEntityBody, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartSend(Boolean completedSynchronously)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin()
at System.ServiceModel.Channels.ServiceChannel.BeginCall(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, TimeSpan timeout, AsyncCallback callback, Object asyncState)
at System.ServiceModel.Channels.ServiceChannel.BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.ServiceChannel.BeginRequest(Message message, AsyncCallback callback, Object state)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.ServiceModel.Channels.IRequestChannel.BeginRequest(Message message, AsyncCallback callback, Object state)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendRequestMessage(IBaseMessage bizTalkMessage, IRequestChannel channel)
at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendMessage(IBaseMessage bizTalkMessage)
MessageId: {9FA7042A-0391-4AAF-946F-FE9C5516ABFD}
InstanceID: {4C29E43D-278A-4615-8A30-4ED1B1CBC2AD}
为什么需要这样做?当我不抑制它时究竟会发生什么?
默认情况下,BizTalk 在发送时会发送消息负载(内容正文)。
当您尝试使用 RESTful 服务并想要执行 GET 时,您通常不想发送消息负载,您也只是从 URL 中获取内容,因此你想禁止发送内容主体。
查看相关问题Cannot send a content-body with this verb-type
如果您发送带有 GET 请求的内容主体会发生什么变化。 一些代理可能会在请求上出现错误或错误,或者终端服务器可能会抛出异常,因为它不期望内容主体。
您需要隐藏 body,而不是动词。这里有一个已构建并可用的自定义管道组件:https://code.msdn.microsoft.com/biztalk-2010-r2-rest-wcf-fdb2e91f 可以为您完成此操作。