一个服务,多个端点,多个绑定在WCF上.为什么我不能到达我的端点?

前端之家收集整理的这篇文章主要介绍了一个服务,多个端点,多个绑定在WCF上.为什么我不能到达我的端点?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个由IIS运行的WCF服务.我想创建两个不同的客户端( WPF和WP7),它们正在使用相同的服务. WPF客户端已经使用wsHttpBinding和https使用端点.可悲的是WP7不做wsHttpBinding,只有BasicHttpBinding.所以我以为我会暴露两个不同的端点,所以他们可以访问相同的服务,但是具有不同的绑定和什么不…

所以这里是我的Web.config在IIS上:

  1. <configuration>
  2.  
  3. <system.web>
  4. <compilation debug="true" targetFramework="4.0" />
  5. </system.web>
  6. <system.serviceModel>
  7. <bindings>
  8. <wsHttpBinding>
  9. <binding name="TransportSecurity">
  10. <reliableSession enabled="true" />
  11. <security mode="TransportWithMessageCredential" >
  12. <transport clientCredentialType="None"/>
  13. </security>
  14. </binding>
  15. </wsHttpBinding>
  16. <basicHttpBinding>
  17. <binding name="BasicTransportSecurity">
  18. <security mode="Transport">
  19. <transport clientCredentialType="None"/>
  20. </security>
  21. </binding>
  22. </basicHttpBinding>
  23. </bindings>
  24. <behaviors>
  25. <serviceBehaviors>
  26. <behavior name="SmartCook2.Server.ISmartCookServiceBehavior">
  27. <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
  28. <serviceDebug includeExceptionDetailInFaults="true" />
  29. </behavior>
  30. </serviceBehaviors>
  31. </behaviors>
  32. <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  33. <services>
  34. <service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior"
  35. name="SmartCook2.Server.SmartCookService">
  36. <endpoint address="WS" binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
  37. name="WS" contract="SmartCook2.Server.ISmartCookService" />
  38. <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="BasicTransportSecurity"
  39. name="Basic" contract="SmartCook2.Server.ISmartCookService" />
  40. <endpoint address="mex" binding="mexHttpsBinding" name="mex"
  41. contract="IMetadataExchange" />
  42. </service>
  43. </services>
  44. </system.serviceModel>
  45. <system.webServer>
  46. <modules runAllManagedModulesForAllRequests="true"/>
  47. </system.webServer>
  48. <connectionStrings>
  49. <add name="SmartCookDBEntities" connectionString="Metadata=res://*/SmartCookContext.csdl|res://*/SmartCookContext.ssdl|res://*/SmartCookContext.msl;provider=System.Data.sqlClient;provider connection string=&quot;data source=RENDERBETYAR;initial catalog=SmartCookDB;integrated security=True;pooling=False;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  50. </connectionStrings>
  51.  
  52. </configuration>

现在如果我得到的话,终端应该可以在以下地址上访问:

  1. https://localhost/IISHostedSmartCook/SmartCookService.svc/Basic
  2. https://localhost/IISHostedSmartCook/SmartCookService.svc/WS
  3. https://localhost/IISHostedSmartCook/SmartCookService.svc/mex

如果我在浏览器中检查,我什么也没有.也没有例外,但也没有内容.使用基地址(直到.svc部分)我得到默认的服务页面,我可以访问wsdl并且它是有效的.据我所知,它具有端点,我的服务方法等.

如果我尝试添加ServiceReference到我的WP7项目是Visual Studio,我只能看到我的服务在基地址(特定的端点地址不返回).如果我添加它,类是生成关于正确的,只有我无法调用任何我的服务的方法,我得到错误消息“没有端点侦听这个地址”. (如果我使用需要端点名称的服务客户端的构造函数,也会发生这种情况)

我究竟做错了什么?

解决方法

检查 here详细说明.

您需要指定的是您的端点中的地址:

  1. <service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior"
  2. name="SmartCook2.Server.SmartCookService">
  3. <endpoint address="http://localhost/Service.svc/WS" binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
  4. name="WS" contract="SmartCook2.Server.ISmartCookService" />
  5. <endpoint address="http://localhost/Service.svc/Basic" binding="basicHttpBinding" bindingConfiguration="BasicTransportSecurity"
  6. name="Basic" contract="SmartCook2.Server.ISmartCookService" />
  7. <endpoint address="" binding="mexHttpsBinding" name="mex"
  8. contract="IMetadataExchange" />
  9. </service>

猜你在找的HTML相关文章