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.
我目前正在开发一个解决方案,它需要使用Silverlight 3.0和标准.NET应用程序作为使用WCF实现的Web服务的客户端。 Silverlight客户端使用的Web服务部分需要双工功能,因此我在服务的一个端点上使用(仍然相当新的)PollingDuplexBindingElement。但是,PDBE仅受Silverlight支持,因此我为其他客户端添加了第二个端点,该端点使用WSDualHttpBinding作为绑定。这些其他客户端实际上并不需要双工,但由于服务器端合同的某些部分需要双工,因此像WSHttpBinding这样的标准单工绑定将不起作用。
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:
由于奇怪的Silverlight WCF要求(例如,重写对HTTP 200的HTTP 500错误响应等),我正在通过自定义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();
}
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.
而且(有点惊人)一切都有效。 Silverlight / PollingDuplex客户端都得到了他们的整齐回调(比SL 2.0好多了!),.NET / WSDualHttp客户端都可以很好地与服务器通信。
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:
除了一件事。当我尝试调试应用程序时,Visual Studio在通过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."
“无法自动调试'MyCompany.Service'。无法调试远程过程。这通常表示尚未在Web服务器上启用调试。有关详细信息,请参阅帮助。”
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.
错误消息不太准确。事实证明,您可以通过任何双工(单向)调用对Web服务进行逐步调试,但不能通过任何单工(双向)调用。
Now, of course, I've checked to confirm that my web.config is setup appropriately, i.e., it has the following line in it:
现在,当然,我已经检查确认我的web.config已正确设置,即它中包含以下行:
<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.
我一直在打击这个问题已经足够长,以至于我已经整理了一个相当简单的复制品(可在这里找到)来证明这个问题。据我所知,当你在IIS中使用WSDualHttpBinding,然后尝试针对该服务进行标准的单工调用时,它会显示出来。
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.
我最初的解决方法是从服务的Simplex部分拆分Duplex,此时一切正常 - 但是以客户端上的重复对象模型为代价,这并不理想。所以我把所有东西都归还给了一个服务,但是不能调试任何东西肯定是痛苦的。
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.
FWIW,我在MSDN上发布了或多或少的同样问题没有任何建议,我试图用MS Connect打开一个错误,但是再次,那个季度没有任何帮助。
Any ideas?
1 个解决方案
#1
Turns out it's a bona fide bug. It should be fixed in VS 2010 Beta 2.
事实证明这是一个真正的错误。它应该在VS 2010 Beta 2中修复。
See here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536&wa=wsignin1.0.
请参阅此处:https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx ?FeedbackID = 472536&wa = newsignin1.0。
#1
Turns out it's a bona fide bug. It should be fixed in VS 2010 Beta 2.
事实证明这是一个真正的错误。它应该在VS 2010 Beta 2中修复。
See here: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536&wa=wsignin1.0.
请参阅此处:https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx ?FeedbackID = 472536&wa = newsignin1.0。