我有一个由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="data source=RENDERBETYAR;initial catalog=SmartCookDB;integrated security=True;pooling=False;multipleactiveresultsets=True;App=EntityFramework"" 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>