2013-11-03 99 views
1

我试图在Win7中用IIS 7.5创建WCF NamedPipe。在Win7 IIS 7.5上托管NamedPipe WCF EndpointNotFoundException

  1. 在IIS管理器中右击,并创建一个名为 “TestWCFWithNamedPipe”
  2. 网页右键点击我的网站 “TestWCFWithNamedPipe” - >选择编辑绑定

    Type:http 
    Host Name:sample.localdev.net 
    Port:80 
    Address:* 
    
    Type:net.pipe 
    Binding informations:* 
    
  3. 在高级设置中设定的值启用议定书 “HTTP,net.pipe”

  4. 在我的网站 “TestWCFWithNamedPipe” Web应用程序项目

web.config

<configuration> 
<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
</system.web> 

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="DefaultBehavior"> 
       <serviceDebug /> 
       <serviceMetadata httpGetEnabled="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="DefaultBehavior" name="SampleWcfLib.SampleWcfObj"> 
      <endpoint address="net.pipe://localhost/Sample" binding="netNamedPipeBinding" 
       bindingConfiguration="" contract="SampleWcfInterfaceLib.ISampleWcfObj" /> 
     </service> 
    </services> 
</system.serviceModel> 

TestClient.exe代码以下

string address = "net.pipe://localhost/Sample"; 
NetNamedPipeBinding binding = new NetNamedPipeBinding(); 
EndpointAddress ep = new EndpointAddress(address); 
ISampleWcfObj channel = ChannelFactory<ISampleWcfObj>.CreateChannel(binding, ep); 
string result = channel.Ping("Test"); 

我跑TestClient.exe,我得到一个异常:

有没有终点在net.pipe:// localhost/Sample中侦听可以接受消息的示例。这通常是由不正确的地址或SOAP操作引起的。有关更多详细信息,请参阅InnerException(如果存在)。

我已经检查了Win7的服务状态:

Net.Pipe Listener Adapter Started 
Net.Tcp Listener Adapter Started 

我已经做了WCF所有设置。

为什么我仍然得到EndpointNotFoundException错误消息?

+0

您设置的网站在IIS sample.localdev.net。你不应该用那个地址吗? – Szymon

+0

我使用net.pipe模式,是net.pipe需要“sample.localdev.net”地址吗? 所以我应该使用“net.pipe://sample.localdev.net/Sample”?我试过了,错了! – Flash

+0

我会放弃它。 – Szymon

回答

2

如果您在XSD文件中查看,可以找到tcp绑定的名称。 这将是对你的文件的底部,它看起来像这样

<wsdl:service name="PersonService"> 
    <wsdl:port name="NetNamedPipeBinding_IPersonContract" binding="tns:NetNamedPipeBinding_IPersonContract"> 
     <soap12:address location="net.pipe://wcftestpipe/WcfTest/PersonService.svc/test"/> 
     <wsa10:EndpointReference> 
      <wsa10:Address>net.pipe://wcftestpipe/WcfTest/PersonService.svc/test</wsa10:Address> 
     </wsa10:EndpointReference> 
    </wsdl:port> 
</wsdl:service> 

Afther你propably得到一个安全exeception会说你没有正确的凭证。您可以在您的客户端的WCF服务和app.config的web.config中将绑定安全模式设置为NONE。

<bindings> 
    <netNamedPipeBinding> 
     <binding> 
     <security mode="None"/> 
     </binding> 
    </netNamedPipeBinding> 
</bindings> 

希望这有助于