将服务引用添加到 net.pipe 服务
我已经开始学习 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();
执行此代码时,服务会正确启动。
现在,当在我的客户端应用程序中,我尝试将服务引用添加到此正在运行的服务时,它无法找到它。有什么我没有做或做得不正确的事情吗?
如果我能在这方面得到任何帮助,我将不胜感激。
干杯, 阿比。
I have started learning WCF and have created a few test http services successfully. Now, i was trying to create a self-hosted WCF service using net.pipe binding. Below is the configuration file for the service:-
<?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>
Now in my host application, I am starting the service using:-
ServiceHost host = new ServiceHost(typeof(MyService));
host.Open();
Console.WriteLine("Service started");
host.Close();
The service starts correctly when this code is executed.
Now, when in my client application, I try to add the service reference to this running service, it is not able to find it. Is there something which I am not doing or doing incorrectly?
I would appreciate any help I can get on this.
Cheers,
Abhi.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该服务随后打开和关闭。当您启动客户端时,服务器已经关闭。所以在关闭之前需要 Console.ReadKey() 。
The service is opened and closed after that. By the time you start the client the server is already closed. So Console.ReadKey() is required is requied before close.