WCF WSDualHttpBinding 错误消息:无法自动调试服务
我目前正在开发一个解决方案,该解决方案需要使用 Silverlight 3.0 和标准 .NET 应用程序作为使用 WCF 实现的 Web 服务的客户端。 Silverlight 客户端使用的 Web 服务部分需要双工功能,因此我在服务的一个端点上使用(仍然相当新的)PollingDuplexBindingElement。 但是,PDBE 仅受 Silverlight 支持,因此我为其他客户端的服务添加了第二个端点,该端点使用 WSDualHttpBinding 作为绑定。 这些其他客户端实际上并不需要双工,但由于服务器端协定的部分需要双工,因此像 WSHttpBinding 这样的标准单工绑定将不起作用。
由于奇怪的 Silverlight WCF 要求(例如,将 HTTP 500 错误响应重写为 HTTP 200 等),我通过自定义 ServiceFactory 类初始化我的服务,其关键部分如下所示:
protected override void InitializeRuntime()
{
// Add the WSDualHttpBinding.
// This should listen at http://<servername>/RoomService.svc/wsdual
WSDualHttpBinding wsDualBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None)
{
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = new System.Text.UTF8Encoding()
};
this.AddServiceEndpoint(
typeof(IRoomService),
wsDualBinding,
"wsdual");
// Add the PollingDuplexBinding
// This should listen at http://<servername>/RoomService.svc
PollingDuplexBindingElement pollingDuplexBindingElement = new PollingDuplexBindingElement()
{
// I'm not sure that these values are the best. They're an initial guess.
ServerPollTimeout = TimeSpan.FromSeconds(90),
InactivityTimeout = TimeSpan.FromMinutes(30)
};
CustomBinding pollingDuplexBinding = new CustomBinding(
pollingDuplexBindingElement,
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement());
this.AddServiceEndpoint(
typeof(IRoomService),
pollingDuplexBinding,
"").Behaviors.Add(new SilverlightFaultBehavior());
// Add the MetaData Exchange binding.
this.AddServiceEndpoint(
typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex");
base.InitializeRuntime();
}
并且(有点令人惊讶)所有内容作品。 Silverlight/PollingDuplex 客户端都获得了简洁的回调(比 SL 2.0 好得多!),.NET/WSDualHttp 客户端都可以与服务器正常通信。
除了一件事。 当我尝试调试应用程序时,Visual Studio 在通过 WSDualHttp 进行第一个单工调用时会抛出以下对话框:
“无法自动调试‘MyCompany.Service’。无法调试远程过程。这通常表明调试尚未在网络服务器上启用。请参阅帮助以获取更多信息。”
错误消息不太准确。 事实证明,您可以通过任何双工(单向)调用对 Web 服务进行逐步调试,但不能通过任何单工(双向)调用。
现在,当然,我已经检查并确认我的 web.config 已正确设置,即其中包含以下行
<compilation debug="true">
: repro(可在此处找到)演示了该问题。 据我所知,当您在 IIS 中使用 WSDualHttpBinding,然后尝试对该服务进行标准单工调用时,它就会出现。
我最初的解决方法是将服务的 Duplex 与 Simplex 部分分开,此时一切工作正常 - 但代价是客户端上存在重复的对象模型,这不理想。 因此,我将所有内容都移回了一项服务,但无法调试任何内容确实很痛苦。
还有其他人遇到过这个吗,或者有什么建议吗?
FWIW,我在 MSDN 没有任何建议,并且我尝试使用 MS 连接,但同样,该季度尚未提供任何帮助。
有任何想法吗?
I'm currently working on a solution which needs to use both Silverlight 3.0 and standard .NET applications as clients to a web service implemented with WCF. The portions of the web service consumed by the Silverlight client need duplex functionality, so I'm using the (still fairly new) PollingDuplexBindingElement on one end point of my service. However, PDBE is only supported by Silverlight, so I've added a second end-point to my service for other clients, which uses WSDualHttpBinding as the binding. These other clients don't actually need duplex, but because portions of the server-side contract require duplex, a standard simplex binding like WSHttpBinding won't work.
Because of the weird Silverlight WCF requirements (e.g., rewriting HTTP 500 fault responses to HTTP 200, etc.), I'm initializing my service through a custom ServiceFactory class, the key portions of which look like this:
protected override void InitializeRuntime()
{
// Add the WSDualHttpBinding.
// This should listen at http://<servername>/RoomService.svc/wsdual
WSDualHttpBinding wsDualBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None)
{
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = new System.Text.UTF8Encoding()
};
this.AddServiceEndpoint(
typeof(IRoomService),
wsDualBinding,
"wsdual");
// Add the PollingDuplexBinding
// This should listen at http://<servername>/RoomService.svc
PollingDuplexBindingElement pollingDuplexBindingElement = new PollingDuplexBindingElement()
{
// I'm not sure that these values are the best. They're an initial guess.
ServerPollTimeout = TimeSpan.FromSeconds(90),
InactivityTimeout = TimeSpan.FromMinutes(30)
};
CustomBinding pollingDuplexBinding = new CustomBinding(
pollingDuplexBindingElement,
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement());
this.AddServiceEndpoint(
typeof(IRoomService),
pollingDuplexBinding,
"").Behaviors.Add(new SilverlightFaultBehavior());
// Add the MetaData Exchange binding.
this.AddServiceEndpoint(
typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex");
base.InitializeRuntime();
}
And (somewhat astonishingly) everything works. The Silverlight/PollingDuplex clients all get their neat-o callbacks (much, much nicer than SL 2.0!), and the .NET/WSDualHttp clients can all talk to the server just fine.
Except for one thing. When I try to debug the application, Visual Studio throws up the following dialog box when it hits the first simplex call over WSDualHttp:
"Unable to automatically debug 'MyCompany.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the web server. See help for more information."
The error message isn't quite accurate. It turns out that you can do step-through debugging into the web service through any duplex (one-way) call, but not through any simplex (two-way) call.
Now, of course, I've checked to confirm that my web.config is setup appropriately, i.e., it has the following line in it:
<compilation debug="true">
I've been beating my head against this long enough that I've put together a fairly straightforward repro (available here) which demonstrates the issue. As best as I can tell, it shows up when you use WSDualHttpBinding within IIS, and then try to make standard simplex calls against that service.
My initial workaround was to split off the Duplex from the Simplex pieces of the service, at which point everything worked just fine -- but at the cost of duplicate object models on the clients, which was not ideal. So I've moved everything back to just one service, but it sure is a pain not to be able to debug anything.
Has anybody else run into this, or have any suggestions?
FWIW, I've posted more-or-less this same question on MSDN with no suggestions, and I've tried to open a bug with MS Connect, but again, no help yet from that quarter.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明这是一个真正的错误。 它应该在 VS 2010 Beta 2 中修复。
请参见此处:https:/ /connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536&wa=wsignin1.0。
Turns out it's a bona fide bug. It should be fixed in VS 2010 Beta 2.
See here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536&wa=wsignin1.0.