由于 DuplexBinding,WCF 服务引用生成空的引用.cs

发布于 2025-01-04 10:30:31 字数 3195 浏览 0 评论 0原文

我有WCF服务。这是配置

  <basicHttpBinding>
    <binding name="EmergencyRegistratorBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </basicHttpBinding>

和服务配置

  <service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="EmergencyRegistratorBinding"
        contract="Services.IEmergencyRegistrator" />
  </service>

一切正常。但我需要将 basicHttpBingind 更改为 DuplexBinding。 我添加了扩展:

<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex"/>
  </bindingElementExtensions>
</extensions>

并将上述行更改为:

  <customBinding>
    <binding name="DuplexmergencyRegistratorBinding">
      <binaryMessageEncoding/>
      <pollingDuplex maxPendingSessions="2147483647" maxPendingMessagesPerSession="2147483647" inactivityTimeout="02:00:00" serverPollTimeout="00:05:00"/>
      <httpTransport authenticationScheme="Negotiate"/>
    </binding>
  </customBinding>

并且

  <service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
    <endpoint address="" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="Breeze.Core.Services.IEmergencyRegistrator" />
    <endpoint address="mex" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="IMetadataExchange"/>
  </service>

我已将服务引用添加到 WCF 项目。引用已成功添加,但 Reference.cs 几乎为空。

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.225
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

当我取消选中选项“重用引用程序集中的类型”时 代码已生成,但有超过 10,000 行而不是 ~500

我运行 svcutil 并得到了下一个:

svcutil.exe http://localhost/Breeze.Workstation/Emergcies/EmergencyRegistrator.svc ?wsdl

尝试从以下位置下载元数据使用 WS-Metadata Exchange 或 DISCO 的“http://localhost/Breeze.Workstation/Emergcies/EmergencyRegistrator.svc?wsdl”。 警告:未导入以下策略断言: XPath://wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_IEmergencyRegistrator'] 断言:..

生成文件... C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\EmergencyRegistrator.cs C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\output.config

我对 WCF 服务相当陌生。我希望有人能够帮助我。 谢谢。

I have WCF service. Here is configuration

  <basicHttpBinding>
    <binding name="EmergencyRegistratorBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>
    </binding>
  </basicHttpBinding>

And service configuration

  <service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="EmergencyRegistratorBinding"
        contract="Services.IEmergencyRegistrator" />
  </service>

Everything worked fine. But I needed to change basicHttpBingind to DuplexBinding.
I have added extention:

<extensions>
  <bindingElementExtensions>
    <add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex"/>
  </bindingElementExtensions>
</extensions>

And changed mentioned above lines to:

  <customBinding>
    <binding name="DuplexmergencyRegistratorBinding">
      <binaryMessageEncoding/>
      <pollingDuplex maxPendingSessions="2147483647" maxPendingMessagesPerSession="2147483647" inactivityTimeout="02:00:00" serverPollTimeout="00:05:00"/>
      <httpTransport authenticationScheme="Negotiate"/>
    </binding>
  </customBinding>

and

  <service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
    <endpoint address="" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="Breeze.Core.Services.IEmergencyRegistrator" />
    <endpoint address="mex" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="IMetadataExchange"/>
  </service>

I have added Service Reference to WCF project. Reference was successfully added but Reference.cs was almost empty.

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.225
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

When I uncheck option "Reuse types in referenced assemblies"
Code is generated but there above 10 thousands lines instead of ~500

I run svcutil and I've got next:

svcutil.exe http://localhost/Breeze.Workstation/Emergencies/EmergencyRegistrator.svc?wsdl

Attempting to download metadata from 'http://localhost/Breeze.Workstation/Emergencies/EmergencyRegistrator.svc?wsdl' using WS-Metadata Exchange or DISCO.
Warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='CustomBinding_IEmergencyRegistrator']
Assertions: ..

Generating files...
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\EmergencyRegistrator.cs
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\output.config

I'm quite new to WCF services. I hope somebody will be able to help me.
Thanks.

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

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

发布评论

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

评论(2

晨光如昨 2025-01-11 10:30:31

我已经解决了。
空引用是由于类型不明确的一些问题造成的。当我修复它时,reference.cs 文件生成良好。

因此,解决方案不仅要查看错误,还要查看警告。我在那里找到了解决我的问题所需的所有信息。快乐编码

I've solved that.
Empty reference was due to some problems with ambiguous types. When I fixed it, reference.cs file generated well.

So, solution is to look not only at errors, but at warnings too. I have found there all information what I need for my problem. Happy codding

惯饮孤独 2025-01-11 10:30:31

仅 Silverlight 客户端支持轮询双工 HTTP 绑定。由于您使用 svcutil 生成引用,我假设您正在为服务器构建一个“普通”(即非 SL)客户端,因此这是行不通的。

如果您想在非 Silverlight 应用程序上使用双工绑定,可以查看 wsDualHttpBindingnetTcpBinding

The polling duplex HTTP binding is only supported by Silverlight clients. Since you're using svcutil to generate the reference, I assume you're building a "normal" (i.e., non-SL) client for the server, so that won't work.

If you want to use a duplex binding on a non-Silverlight application, you can take a look at either the wsDualHttpBinding or netTcpBinding.

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