【发布时间】:2011-06-15 21:01:58
【问题描述】:
我正在测试 WCF 4 的无配置功能。
我已经构建了一个简单的服务并将其部署到 IIS。服务部署为 svc 文件
客户端配置为空:
<configuration>
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>
</configuration>
网络服务器上的配置是:
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
这段代码运行良好:
BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress("http://localhost/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);
这段代码没有:
NetTcpBinding myBinding = new NetTcpBinding();
EndpointAddress myEndpoint = new EndpointAddress("net.tcp://localhost:808/Service1.svc");
ChannelFactory<IService1> myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
IService1 wcfClient1 = myChannelFactory.CreateChannel();
int z = wcfClient1.Multiply(composite);
我得到的错误是:
无法连接到 net.tcp://localhost/Service1.svc。这 连接尝试持续了一段时间 跨度为 00:00:02.1041204。 TCP 错误 代码 10061:无法连接 因为目标机器而制造 127.0.0.1:808 主动拒绝。
net.tcp 绑定是在默认网站上设置的。
我有一种感觉,我缺少一些简单的东西。有人有什么想法吗?
【问题讨论】: