是否可以从 WCF 回调到 ASP.NET?

发布于 2024-09-25 20:53:21 字数 643 浏览 1 评论 0原文

我在不同的盒子中的 IIS 中托管了一个 Web 服务,在另一个盒子中的 Windows 服务中托管了 WCF 服务。(N 层方法)。这里,Web服务是WCF服务的客户端。上传文件的请求到达 IIS 托管的 Web 服务,该 IIS 托管的 Web 服务反过来调用 WCF 服务并执行实际的上传。到目前为止,一切都很好。上传完成后,WCF 服务执行回调(我已将回调存储在字典中,并且使用了 (InstanceContextMode=InstanceContextMode.PerSession, ConcurrencyMode=ConcurrencyMode.Multiple))。 WCF 服务发送回调。在跟踪查看器中,看起来 ASP.NET 收到了回调,但浏览器中的上传页面(这是最终用户)永远冻结了。 我正在使用 larsw 的 ChunkingChannel 绑定。

首先,是否有可能实现上述方案,正如 John Saundars 在此链接中提到的:

“OperationContext.Current.GetCallbackChannel”实际上是做什么的?

感谢您的帮助。

I have a Web service hosted in IIS in different box and WCF service hosted in Windows service, in a different box.(N-tier approach). Here, Web service is a client for WCF service. The request to upload the file comes to the IIS hosted Web service, and this IIS hosted Web service in return calls the WCF service and does the actual upload. So far so good. After the upload is done the WCF service performs the callback (I have stored the callbacks in dictionary, and I have used (InstanceContextMode=InstanceContextMode.PerSession, ConcurrencyMode=ConcurrencyMode.Multiple)). The WCF service sends the callback. In the trace viewer, it looks like the ASP.NET received the callback, but the upload page in browser(this is the end user) freezes for good.
I am using ChunkingChannel binding by larsw.

First of all, is it at all possible to implement the above senario, as John Saundars mentioned in this link:

What does "OperationContext.Current.GetCallbackChannel" actually do?

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

通知家属抬走 2024-10-02 20:53:22

奇怪的是,我重新启动了计算机,现在在客户端 (ASP.NET) 端的跟踪查看器中看到以下内容,而且页面现在不会冻结(无响应)。最让我担心的消息是它的内部异常:System.NullReferenceException,mscorlib 并说对象引用不是...

我尝试使用控制台应用程序作为 WCF 服务的客户端。回调效果很好。仅当我在 IIS 中托管我的网站并调用 WCF 服务上传文件时(返回回调到客户端以通知上传成功/不成功)。

(我正在使用 HttpChunkingBinding)。
有什么想法吗?

System.Runtime.FatalException,
System.Runtime.DurableInstancing,版本=4.0.0.0,文化=中性,
PublicKeyToken=31bf3856ad364e35 对象
未设置对对象实例的引用。

System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
远程过程调用)在
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) 在 System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)位于
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext
请求、布尔 cleanThread、OperationContext
当前操作上下文)位于
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
请求,OperationContext currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.b_2(AsyncCallback
回调,IAsyncResult 结果)
System.Runtime.AsyncResult.Complete(布尔已完成同步)在
System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() 在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo
信息)在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult
结果)在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在 System.Runtime.AsyncResult.Complete(Boolean
同步完成)于
System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.b_2(AsyncCallback
回调,IAsyncResult 结果)
System.Runtime.AsyncResult.Complete(布尔已完成同步)在
System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() 在
System.Runtime.ActionItem.DefaultActionItem.Invoke() 在
System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(对象
状态)在
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32
错误代码,UInt32 numBytes,NativeOverlapped* nativeOverlapped) at
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
错误,UInt32 bytesRead,NativeOverlapped* nativeOverlapped) at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
错误代码、UInt32 numBytes、NativeOverlapped* pOVERLAP)
System.Runtime.FatalException:对象引用不
设置为对象的实例。 --->
System.NullReferenceException:未将对象引用设置到实例
一个物体的。在
System.Web.HttpApplication.ThreadContext.Enter(布尔值
setImpersonationContext)位于
System.Web.HttpApplication.OnThreadEnterPrivate(布尔值
setImpersonationContext)位于
System.Web.AspNetSynchronizationContext.CallCallback可能UnderLock(SendOrPostCallback
回调,对象状态)位于
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
回调,对象状态)位于
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) --- 内部异常堆栈跟踪结束 --- at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
远程过程调用)在
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) 在 System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet)位于
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext
请求、布尔 cleanThread、OperationContext
当前操作上下文)位于
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
请求,OperationContext currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.b_2(AsyncCallback
回调,IAsyncResult 结果)
System.Runtime.AsyncResult.Complete(布尔值同步完成)
在 System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) 处
System.Runtime.InputQueue
1.Dispatch() 在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo
信息)在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult
结果)在
System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在 System.Runtime.AsyncResult.Complete(Boolean
同步完成)于
System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult
结果)在
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
结果)在
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.b_2(AsyncCallback
回调,IAsyncResult 结果)
System.Runtime.AsyncResult.Complete(布尔值同步完成)
在 System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) 处
System.Runtime.InputQueue
1.Dispatch() 在
System.Runtime.ActionItem.DefaultActionItem.Invoke() 在
System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(对象
状态)在
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32
错误代码,UInt32 numBytes,NativeOverlapped* nativeOverlapped) at
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
错误,UInt32 bytesRead,NativeOverlapped* nativeOverlapped) at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
错误代码、UInt32 numBytes、NativeOverlapped*
p重叠)
System.NullReferenceException,mscorlib,
版本=4.0.0.0,文化=中立,
PublicKeyToken=b77a5c561934e089 对象
未设置对对象实例的引用。
在 System.Web.HttpApplication.ThreadContext.Enter(布尔值
setImpersonationContext)位于
System.Web.HttpApplication.OnThreadEnterPrivate(布尔值
setImpersonationContext)位于
System.Web.AspNetSynchronizationContext.CallCallback可能UnderLock(SendOrPostCallback
回调,对象状态)位于
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
回调,对象状态)位于
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) System.NullReferenceException:
你调用的对象是空的。在
System.Web.HttpApplication.ThreadContext.Enter(布尔值
setImpersonationContext)位于
System.Web.HttpApplication.OnThreadEnterPrivate(布尔值
setImpersonationContext)位于
System.Web.AspNetSynchronizationContext.CallCallback可能UnderLock(SendOrPostCallback
回调,对象状态)位于
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
回调,对象状态)位于
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
远程过程调用)

It is weired, I restarted the computer and now am getting the following in Trace viewer in the client (ASP.NET) side, and also the page doesn't freezes(unresponsive) now. The message that most concerns me is its inner exception: System.NullReferenceException, mscorlib and says Object reference not...

I tried with Console Application as a client to WCF Service. The callback works great. It is only when I host my website in IIS and call WCF service to upload file(which in return calls back to the client to notify that the upload was/not successful).

(I am using HttpChunkingBinding).
Any idea?

System.Runtime.FatalException,
System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35 Object
reference not set to an instance of an object.
at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet) at
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext
request, Boolean cleanThread, OperationContext
currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
request, OperationContext currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback
callback, IAsyncResult result) at
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at
System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo
info) at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult
result) at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at System.Runtime.AsyncResult.Complete(Boolean
completedSynchronously) at
System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback
callback, IAsyncResult result) at
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) at
System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() at
System.Runtime.ActionItem.DefaultActionItem.Invoke() at
System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object
state) at
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
System.Runtime.FatalException: Object reference not
set to an instance of an object. --->
System.NullReferenceException: Object reference not set to an instance
of an object. at
System.Web.HttpApplication.ThreadContext.Enter(Boolean
setImpersonationContext) at
System.Web.HttpApplication.OnThreadEnterPrivate(Boolean
setImpersonationContext) at
System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback
callback, Object state) at
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
callback, Object state) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) --- End of inner exception stack trace --- at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean
isOperationContextSet) at
System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext
request, Boolean cleanThread, OperationContext
currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
request, OperationContext currentOperationContext) at
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback
callback, IAsyncResult result) at
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.ProcessDuplexMessage(WsrmMessageInfo
info) at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.HandleReceiveComplete(IAsyncResult
result) at
System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnReceiveCompletedStatic(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at System.Runtime.AsyncResult.Complete(Boolean
completedSynchronously) at
System.ServiceModel.Channels.ReliableChannelBinder1.InputAsyncResult1.OnInputComplete(IAsyncResult
result) at
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result) at
System.ServiceModel.Diagnostics.TraceUtility.<>c_DisplayClass4.<CallbackGenerator>b_2(AsyncCallback
callback, IAsyncResult result) at
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) at
System.Runtime.InputQueue
1.Dispatch() at
System.Runtime.ActionItem.DefaultActionItem.Invoke() at
System.Runtime.ActionItem.CallbackHelper.InvokeWithoutContext(Object
state) at
System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) at
System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) at
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped*
pOVERLAP)
System.NullReferenceException, mscorlib,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 Object
reference not set to an instance of an object.
at System.Web.HttpApplication.ThreadContext.Enter(Boolean
setImpersonationContext) at
System.Web.HttpApplication.OnThreadEnterPrivate(Boolean
setImpersonationContext) at
System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback
callback, Object state) at
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
callback, Object state) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc) System.NullReferenceException:
Object reference not set to an instance of an object. at
System.Web.HttpApplication.ThreadContext.Enter(Boolean
setImpersonationContext) at
System.Web.HttpApplication.OnThreadEnterPrivate(Boolean
setImpersonationContext) at
System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback
callback, Object state) at
System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback
callback, Object state) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc)

独孤求败 2024-10-02 20:53:21

不确定您所说的“冻结”是什么意思,这只是它不更新还是变得无响应。

可能是在响应从 wcf 服务返回到 Web 服务器之前,asp 页面的响应已发送到浏览器。在这种情况下,当结果从服务返回时,asp 页面将不会更新。

您有 2 个选择:

  • 使用 javascript 轮询服务器以了解更改。
  • 阻止上传页面的返回,直到从服务收到响应。

如果您最终等待回调,那么仅执行请求响应样式会更简单。

另一个常见问题是客户端上的 wcf 代理在收到回调之前关闭。痕迹显示它回来了,但没有人在听。

Not sure what you mean by "freezes", is this just that it does not update or that it becomes unresponsive.

It may be that the response for the asp page is sent to the browser before the response comes back to the web server from the wcf service. In this case the asp page will not get updated when the result comes back from the service.

You have 2 options:

  • Use javascript to poll the server for changes.
  • Block the return of the upload page untill the response is received from the service.

If you endup waiting for the call back, then it would be simpler just to do a request response style.

Another common probliem is that the wcf proxy on the client gets closed before the callback is received. The trace would show it coming back, but nobody is listening.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文