Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF问题-公开服务_Wcf_Wcf Security - Fatal编程技术网

WCF问题-公开服务

WCF问题-公开服务,wcf,wcf-security,Wcf,Wcf Security,我们需要以下类型的服务: 公开提供。使用X509证书对用户进行身份验证 内部的。被我们的网站消费。用户在网站上经过身份验证,用户名传递给服务 公开提供。用户根据与其IP地址匹配的传入令牌进行身份验证(我们需要支持传统功能) 现在,我通过在WCF服务项目中创建SVC文件实现了#1。这些在配置文件中配置。我没有在该部分中指定任何内容,而且SVC文件似乎使用默认绑定(没有name属性的绑定)。这听起来对吗 如果要实现其他类型的服务,我需要在web.config的部分中指定服务并将它们指向其特定的绑定/

我们需要以下类型的服务:

  • 公开提供。使用X509证书对用户进行身份验证
  • 内部的。被我们的网站消费。用户在网站上经过身份验证,用户名传递给服务
  • 公开提供。用户根据与其IP地址匹配的传入令牌进行身份验证(我们需要支持传统功能)
  • 现在,我通过在WCF服务项目中创建SVC文件实现了#1。这些在配置文件中配置。我没有在该部分中指定任何内容,而且SVC文件似乎使用默认绑定(没有name属性的绑定)。这听起来对吗

    如果要实现其他类型的服务,我需要在web.config的部分中指定服务并将它们指向其特定的绑定/行为,或者创建三个单独的服务项目。最佳做法是什么

    我们希望使用T4模板自动生成我们的服务(svc文件)。到目前为止,这一直有效,但如果我继续,我必须生成web.config文件(这使得维护变得很困难)。有没有办法拆分配置文件的system.service model部分

    谢谢。

    web.config(和app.config)文件可以拆分为单独的文件,如下所示。如果需要,可以封装整个system.serviceModel元素

    <system.serviceModel>
        <services configSource="services.config" />
    
        <behaviors configSource="behavior.config" />
    
        <bindings>
            <wsHttpBinding>
                <binding name="Http" receiveTimeout="00:10:00">
                    <security mode="None">
                        <transport clientCredentialType="None" />
                        <message clientCredentialType="None" establishSecurityContext="false" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
    
        <!-- rest of WCF elements inline as in the bindings element or in other files -->
    </system.serviceModel>
    
    
    
    您只需要创建每个引用的文件。这是一种将特定于环境(即Dev、QA、Staging、Prod)的设置放在单独文件中的好方法,这样您就可以参数化部署脚本