微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我有一个由IIS运行的WCF服务.我想创建两个不同的客户端( WPF和WP7),它们正在使用相同的服务. WPF客户端已经使用wsHttpBinding和https使用端点.可悲的是WP7不做wsHttpBinding,只有BasicHttpBinding.所以我以为我会暴露两个不同的端点,所以他们可以访问相同的服务,但是具有不同的绑定和什么不…

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

<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
        <reliableSession enabled="true" />
          <security mode="TransportWithMessageCredential" >
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
      <basicHttpBinding>
        <binding name="BasicTransportSecurity">
           <security mode="Transport">
              <transport clientCredentialType="None"/>
           </security>
         </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SmartCook2.Server.ISmartCookServiceBehavior">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
      <service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior"
        name="SmartCook2.Server.SmartCookService">
        <endpoint address="WS" binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
          name="WS" contract="SmartCook2.Server.ISmartCookService" />
        <endpoint address="Basic" binding="basicHttpBinding" bindingConfiguration="BasicTransportSecurity"
          name="Basic" contract="SmartCook2.Server.ISmartCookService" />
        <endpoint address="mex" binding="mexHttpsBinding" name="mex"
          contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
<connectionStrings>
    <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" />
  </connectionStrings>

</configuration>

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

https://localhost/IISHostedSmartCook/SmartCookService.svc/Basic
https://localhost/IISHostedSmartCook/SmartCookService.svc/WS
https://localhost/IISHostedSmartCook/SmartCookService.svc/mex

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

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

我究竟做错了什么?

解决方法

检查 here详细说明.

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

<service behaviorConfiguration="SmartCook2.Server.ISmartCookServiceBehavior"
    name="SmartCook2.Server.SmartCookService">
    <endpoint address="http://localhost/Service.svc/WS" binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
      name="WS" contract="SmartCook2.Server.ISmartCookService" />
    <endpoint address="http://localhost/Service.svc/Basic" binding="basicHttpBinding" bindingConfiguration="BasicTransportSecurity"
      name="Basic" contract="SmartCook2.Server.ISmartCookService" />
    <endpoint address="" binding="mexHttpsBinding" name="mex"
      contract="IMetadataExchange" />
  </service>

原文地址:https://www.jb51.cc/html/230395.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐