开发者

WCF Questions - Exposing Services

开发者 https://www.devze.com 2023-03-13 05:35 出处:网络
We have the need for the following kinds of services: Publicly available.User is authenticated with a X509 certificate,

We have the need for the following kinds of services:

  1. Publicly available. User is authenticated with a X509 certificate,
  2. In开发者_开发百科ternal. Consumed by our web site. User is authenticated on the web site and username is passed on to the service.
  3. Publicly available. User is authenticated based on a passed in token matched to their IP address (legacy functionality we need to support).

Right now, I've implemented #1 by creating SVC files in a WCF Service project. These are configured in a config file. I don't specify anything in the section and it seems as though the SVC files use the default bindings (the ones without a name attribute). Does this sound correct?

If I am to implemented the other types of services, I need to either specify the services in the section in the web.config and point them to their specific bindings/behaviors, or create three separate services projects. What would be the best practice?

We want to auto generate our services (the svc files) using T4 templates. This has worked up until now, but if I continue, I have to generate the web.config file (which makes maintenance on it hard). Is there any way to split out the system.service model section of the config file?

Thanks.


The web.config (and app.config) files can be split into separate files as shown below. You could encapsulate the entire system.serviceModel element if that is what you want.

<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>

You would just need to create each of the referenced files. This is a great way of putting environment (i.e. Dev, QA, Staging, Prod) specific settings in separate files so you can parameterize the deployment script.

0

精彩评论

暂无评论...
验证码 换一张
取 消