![](/img/trans.png)
[英]Sometimes adding a WCF Service Reference generates an empty reference.cs
[英]WCF Service Reference generates an empty reference.cs due to DuplexBinding
我有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>
我已將Service Reference添加到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>
//------------------------------------------------------------------------------
當我取消選中“ 在引用的程序集中重用類型 ”選項時,會生成代碼,但超過1萬行而不是約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: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服務的新手。 我希望有人能夠幫助我。 謝謝。
我已經解決了。 空引用是由於模棱兩可的類型存在一些問題。 修復后,reference.cs文件生成良好。
因此,解決方案不僅要看錯誤,還要看警告。 我已經找到了解決問題所需的所有信息。 快樂披着
僅Silverlight客戶端支持輪詢雙工HTTP綁定。 由於您正在使用svcutil
生成引用,因此我假設您正在為服務器構建一個“普通”(即非SL)客戶端,因此將無法使用。
如果要在非Silverlight應用程序上使用雙工綁定,則可以查看wsDualHttpBinding
或netTcpBinding
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.