我正在尝试使用WCF4来设置一个RESTful web服务。我希望该服务是可以使用HTTP和HTTPS访问。默认情况下,使用以下配置创建服务,该配置适用于http,但不适用于https:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" />
</protocolMapping>
</system.serviceModel>然后,我可以通过稍微更改配置来打开该服务的HTTPS:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding >
<binding name="SecureWebBinding" >
<security mode="Transport"></security>
</binding>
</webHttpBinding>
</bindings>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" bindingConfiguration="SecureWebBinding"/>
</protocolMapping>
</system.serviceModel>我的问题是,如何让服务同时使用这两种服务?
发布于 2011-11-09 12:52:39
您应该尝试创建两个独立的端点。例如,
<system.serviceModel>
<services>
<service name="MyNameSpace.MyService">
<endpoint address="https://www.example.com/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="SecureWebBinding"
contract="MyNameSpace.IMyContract" />
<endpoint address="http://www.example.com/MyService.svc"
binding="basicHttpBinding"
contract="MyNameSpace.IMyContract" />
</service>
<bindings>
<webHttpBinding >
<binding name="SecureWebBinding" >
<security mode="Transport"></security>
</binding>
</webHttpBinding>
</bindings>
</services>
</system.serviceModel>https://stackoverflow.com/questions/8059848
复制相似问题