由于 DuplexBinding,WCF 服务引用生成一个空的 reference.cs [英] WCF Service Reference generates an empty reference.cs due to DuplexBinding

查看:19
本文介绍了由于 DuplexBinding,WCF 服务引用生成一个空的 reference.cs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 WCF 服务.这是配置

I have WCF service. Here is configuration

  <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.我添加了扩展名:

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>

  <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 几乎为空.


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>
//------------------------------------------------------------------------------

当我取消选中在引用的程序集中重用类型"选项时代码生成但有超过 1 万行而不是约 500 行

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

我运行 svcutil,然后我有下一个:

I run svcutil and I've got next:

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

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

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

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: ..

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

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

我对 WCF 服务很陌生.我希望有人能够帮助我.谢谢.

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

推荐答案

我已经解决了.空引用是由于不明确类型的一些问题造成的.当我修复它时,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

这篇关于由于 DuplexBinding,WCF 服务引用生成一个空的 reference.cs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆