调用 WCF 客户端函数在 IIS 上不起作用
我使用 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>
I made a service using the WCF discovery. Everything works fine when it is deployed on a specific port (using VS2010 debug), but when I try to deploy it to IIS it finds the service but can't run any of the methods.
This is the code:
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();
When tring to run the client.getMsg()
method I get the following error:
EndpointNotFoundException:
There was no endpoint listening at
http://computerName.domain/services/Service.svc that could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details.
But I got the address, meaning it found it. And if I use the debug deployer (not to iis) I find it in http://localhost:port/services/Service.svc
and it runs perfectly fine. How can I have it deployed to iis with no problems?
OS : win7 64 bit
config file :
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先尝试在浏览器中 GET http://computerName.domain/services/Service.svc -您要么收到错误信息,要么收到服务描述。
First try to GET http://computerName.domain/services/Service.svc in your browser - either you get an error or service description..