WCF Service Reference generates an empty reference.cs due to DuplexBinding

穿精又带淫゛_ 提交于 2019-12-04 06:06:05

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/9224525/wcf-service-reference-generates-an-empty-reference-cs-due-to-duplexbinding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!