一个服务,多个端点,WCF上的多个绑定.为什么我无法达到我的终点?

Ten*_*iko 13 iis https wcf web-config windows-phone-7

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

这是我在IIS上的Web.config:

<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>
Run Code Online (Sandbox Code Playgroud)

现在,如果我做对了,应该可以在以下地址访问端点:

https://localhost/IISHostedSmartCook/SmartCookService.svc/Basic
https://localhost/IISHostedSmartCook/SmartCookService.svc/WS
https://localhost/IISHostedSmartCook/SmartCookService.svc/mex
Run Code Online (Sandbox Code Playgroud)

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

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

我究竟做错了什么?

com*_*ech 0

我相信您可能需要将端点地址更改为相对位置:

<endpoint address="/WS" 
Run Code Online (Sandbox Code Playgroud)

<endpoint address="/Basic"
Run Code Online (Sandbox Code Playgroud)

mex 地址是一种特殊情况,因此不需要更改。

有关更多详细信息,请参阅 MSDN 文档指定端点地址。