BizTalk REST调用仅在Fiddler运行时才有效

时间:2016-10-20 16:40:18

标签: wcf oauth http-headers biztalk fiddler

我有一个BizTalk 2013r2应用程序,它具有使用WCF-WebHttp适配器的请求响应发送端口。发送端口使用我开发的自定义WCF行为来附加OAuth授权标头,可以看到here的详细信息。从我的Azure dev vm运行时,一切都很棒,但我刚刚在一个本地BizTalk服务器上运行,这是它需要在现场运行的地方,我遇到了问题!

通过调整发送端口适配器配置页面的“代理”选项卡中的设置,我尝试了一些方案:

  • 通过公司代理 - 失败
  • 指向目标Web服务,无代理 - 失败
  • 通过提琴手 - 作品
  • 本地模拟服务(由SoapUi托管) - 作品

如果请求是通过公司代理或直接创建的(已创建网络规则以允许此操作),那么我会收到 EndpointNotFound 异常

当针对失败的请求运行WCF跟踪时,我得到以下“消息日志跟踪”:

enter image description here

很快跟进:

enter image description here

第二个请求似乎与第一个请求相同,只是添加了一个Addressing元素,并带有一个空的Action元素。我可以看到第二个是带有source = TransportSend 的日志,而第一个是source = ServiceLevelSendRequest 。在第二个日志之后,我立即看到了异常:

<ExceptionType>System.ServiceModel.EndpointNotFoundException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>There was no endpoint listening at https://api-sandbox.tradeshift.com/tradeshift/rest/external/documents/dispatcher/?documentId=66553703-4f22-4294-9a28-1f3ecb22fcf2&documentProfileId=tradeshift.order.1.0 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.</Message>
<StackTrace>
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.CompleteGetRequestStream(IAsyncResult result)
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStreamAsyncResult.OnGetRequestStream(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.HttpWebRequest.SetResponse(Exception E)
at System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult)
at System.Net.Connection.CompleteConnectionWrapper(Object request, Object state)
at System.Net.PooledStream.ConnectionCallback(Object owningObject, Exception e, Socket socket, IPAddress address)
at System.Net.ServicePoint.ConnectSocketCallback(IAsyncResult asyncResult)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>

我通过Fiddler发出请求后,我看到相同的两个出站日志,一个用于 ServiceLevelSendRequest ,另一个用于 TransportSend 。然后我看到 TransportReceive ,然后是 ServiceLevelReceiveReply ,两者都包含一个HttpResponse元素

我很感激有关如何解决此问题的任何建议,以便可以通过公司代理或直接提出请求 - 坚持在实时服务器上运行Fiddler并不是一个真正的选择!

1 个答案:

答案 0 :(得分:1)

今天早上与一位能够在公司代理上运行跟踪的LAN工程师进行了一次精彩的会议。我们运行了这些测试:

  1. 发送了彻底的小提琴手 - 它有效,可以看到小提琴手正在通过公司代理进行路由
  2. 关闭小提琴手,重试测试 - 它失败但工程师看不到任何痕迹
  3. 捂脸!我意识到我仍然将发送端口代理设置为127.0.0.1:8888 for fiddler
  4. 将发送端口更改为使用公司代理 - 它工作正常!
  5. 工程师确实注意到从api-sandbox.tradeshift.com返回的目标IP地址确实有所不同。所以它似乎在他们身边的负载平衡。我们的公司防火墙没有每台服务器的地址,所以这或许可以解释为什么我上周无法让BizTalk通过我们的公司代理工作。