【发布时间】:2011-08-23 15:14:36
【问题描述】:
我使用 WCF 发现创建了一项服务。将其部署在特定端口上时一切正常(使用 VS2010 调试),但是当我尝试将其部署到 IIS 时,它找到了服务但无法运行任何方法。
这是代码:
DiscoveryClient discoverclient = new DiscoveryClient(new UdpDiscoveryEndpoint());
FindResponse response = discoverclient.Find(new FindCriteria(typeof(IService)));
EndpointAddress address = response.Endpoints[0].Address;
ServiceClient client = new ServiceClient(new BasicHttpBinding(), address);
Console.WriteLine(client.getMsg()); //some test function
Console.ReadKey();
当我尝试运行client.getMsg() 方法时,出现以下错误:
EndpointNotFoundException:
没有端点监听 http://computerName.domain/services/Service.svc 可以接受 信息。这通常是由不正确的地址或 SOAP 操作引起的。 有关详细信息,请参阅 InnerException(如果存在)。
但我得到了地址,这意味着它找到了。如果我使用调试部署器(而不是 iis),我会在 http://localhost:port/services/Service.svc 中找到它,它运行得非常好。我怎样才能毫无问题地将它部署到 iis?
操作系统:win7 64位
配置文件:
<services>
<service behaviorConfiguration="RemoteDeploy.Service1Behavior"
name="RemoteDeploy.Service">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
contract="RemoteDeploy.IService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint name="udpDiscoveryEpt" kind="udpDiscoveryEndpoint" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RemoteDeploy.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceDiscovery>
</serviceDiscovery>
</behavior>
</serviceBehaviors>
</behaviors>
【问题讨论】:
-
也许您需要将 svc 映射添加到 IIS? (ServiceModelReg.exe -i)
-
能否请您发布您的 web.config 文件,至少在您配置端点的位置。多次使用 WCF 服务时,所有问题都与其配置有关。
标签: c# wcf web-services discovery service-discovery