[英]Adding Service Reference to a net.pipe service
我已經開始學習WCF,並成功創建了一些測試http服務。 現在,我試圖使用net.pipe綁定創建一個自托管的WCF服務。 以下是該服務的配置文件:-
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MEX" name="InProcService.MyService">
<endpoint address="MyService"
binding="netNamedPipeBinding" bindingConfiguration="" contract="InProcService.IMyService" />
<endpoint address="Mex" binding="mexNamedPipeBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/InProcService/" />
<add baseAddress="http://localhost:8001/InProcService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MEX" >
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
現在在主機應用程序中,我使用以下命令啟動服務:
ServiceHost host = new ServiceHost(typeof(MyService));
host.Open();
Console.WriteLine("Service started");
host.Close();
執行此代碼后,服務將正確啟動。
現在,當在我的客戶端應用程序中時,我嘗試將服務引用添加到此正在運行的服務中,但找不到它。 是否有我沒有做或做錯的事情?
我將不勝感激。
干杯,阿比。
此后將打開和關閉該服務。 在啟動客戶端時,服務器已關閉。 因此,關閉前需要Console.ReadKey()是必需的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.