您如何安全地享受宁静的WCF服务? [英] How do you security at restful WCF service?

查看:75
本文介绍了您如何安全地享受宁静的WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在开发一个wcf restful and soap服务。我在服务接口中使用WebGet属性。我在配置文件中定义binding =webHttpBinding。你如何安全地享受宁静的WCF服务?



我的服务模型节点:

Hi,

I am developing a wcf restful and soap service. I use WebGet attribute in service interface. I define binding="webHttpBinding" in configuration file. How do you security at restful WCF service?

My servicemodel node :

<system.serviceModel>
    <services>

      <service name="TestService.LisansService" behaviorConfiguration="ServiceBehaviors" >
        <endpoint contract="TestService.ILisansService" binding="wsHttpBinding" />
        <endpoint address="json" binding="webHttpBinding" contract="TestService.ILisansService"  behaviorConfiguration="RestServiceBindingBehaviorJSON" bindingConfiguration="webHttpBindingJSON"></endpoint>
        <endpoint address="xml" binding="webHttpBinding" contract="TestService.ILisansService" behaviorConfiguration="RestServiceBindingBehaviorXML" bindingConfiguration="webHttpBindingXml"></endpoint>

      </service>

    </services>

    <behaviors>
      <endpointBehaviors>
        <behavior name="RestServiceBindingBehaviorJSON">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" />
        </behavior>
        <behavior name="RestServiceBindingBehaviorXML">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Xml" />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>


        <behavior name="ServiceBehaviors">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceCredentials>
            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName"

                             storeLocation="LocalMachine" storeName="My" />
            <userNameAuthentication userNamePasswordValidationMode="Custom"

             customUserNamePasswordValidatorType="TestService.UserAuthentication, TestService" />
          </serviceCredentials>
        </behavior>
        
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <wsHttpBinding>
        <binding>
          <security mode="Message">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>
      <webHttpBinding>

        <binding name="webHttpBindingXml"></binding>
        <binding name="webHttpBindingJSON">
          <security mode="Transport"></security>
        </binding>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>





谢谢。



Thanks.

推荐答案

这篇关于您如何安全地享受宁静的WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆