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

时间:2012-02-10 08:00:38

标签: wcf pollingduplexhttpbinding custom-binding

我有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万行代替~500

我运行了svcutil,然后我就有了:

  

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

尝试使用WS-Metadata Exchange或DISCO从'http://localhost/Breeze.Workstation/Emergencies/EmergencyRegistrator.svc?wsdl'下载元数据。 警告:未导入以下策略声明:   的XPath:// WSDL:定义[@的targetNamespace =的 'http://tempuri.org/'] / WSDL:结合[@名称= '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服务很新。我希望有人能够帮助我。 感谢。

2 个答案:

答案 0 :(得分:5)

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

因此,解决方案不仅要看错误,还要看警告。我发现了我的问题需要的所有信息。快乐编码

答案 1 :(得分:0)

只有Silverlight客户端支持轮询双工HTTP绑定。由于您使用svcutil生成引用,我假设您正在为服务器构建“正常”(即非SL)客户端,因此无法使用。

如果要在非Silverlight应用程序上使用双面打包,可以查看wsDualHttpBindingnetTcpBinding