[英]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.