在IIS上调用WCF客户端函数不起作用
本文关键字:客户端 函数 不起作用 WCF 调用 IIS | 更新日期: 2023-09-27 18:06:31
我使用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>
首先尝试在浏览器中获取http://computerName.domain/services/Service.svc -您可能会得到一个错误或服务描述。