从另一台电脑访问WCF服务
我在这上面花了很多时间,但就是无法让它发挥作用。也许我对托管 WCF 服务并为其创建客户端的理解不正确。
我的网站添加了一个 WCF 服务,具有以下配置...
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyWCFWebApp.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyWCFWebApp.Service1Behavior" name="MyWCFWebApp.Service1">
<endpoint address="" binding="wsHttpBinding" contract="MyWCFWebApp.IService1" bindingConfiguration="Binding1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
当我使用内置 Web 服务器通过 Visual Studio 运行网站时,我可以通过 http://localhost:9988/Service1.svc
但是...
通过cassiniDev Server托管网站时,绑定到ip和主机名,我可以访问wcf服务通过 http://localhost:9988/Service1.svc,但是一旦我尝试使用ip访问wcf服务或主机名 http://10.111.202.73:9988/Service1.svc,它返回以下错误:
“没有协议绑定与给定地址'http://10.111.202.73匹配: 9988/Service1.svc'。协议绑定是在 IIS 或 WAS 配置中的站点级别配置的。”
我不知道为什么会发生这种情况。有什么想法吗?
I've spend hours and hours on this and simply can't get it to work. Maybe my understanding of hosting WCF service and creating a client for it isn't correct.
My website has a WCF Service added to it, with the following config...
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="Binding1">
<security mode="None">
<transport clientCredentialType="None" />
<message establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyWCFWebApp.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyWCFWebApp.Service1Behavior" name="MyWCFWebApp.Service1">
<endpoint address="" binding="wsHttpBinding" contract="MyWCFWebApp.IService1" bindingConfiguration="Binding1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
When I run the website through Visual Studio using build in web server, I can access the webservice through http://localhost:9988/Service1.svc
but...
When hosting the web site through cassiniDev Server, binding to ip and hostname, I can access the wcf service through http://localhost:9988/Service1.svc, but as soon as I try to access the wcf service using ip or hostname http://10.111.202.73:9988/Service1.svc, it returns the following error:
"No protocol binding matches the given address 'http://10.111.202.73:9988/Service1.svc'. Protocol bindings are configured at the Site level in IIS or WAS configuration."
I have no idea why this is happening. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以事实证明这个问题与 cassinidev webservice 有关,它不支持 WCF 3.5....我花了一段时间才弄清楚这个问题...
So it turns out the issue was related to cassinidev webservice, which doesn't support WCF 3.5.... Took me a while to figure that one out...
也许您可以尝试在控制台应用程序中托管您的服务,就像测试它是否与 IIS 相关一样。
maybe you can try to host your service in a console app, just as test to see if it's IIS related.