[ACCEPTED]-How to config clients for a wcf service?-wcf

Accepted answer
Score: 10

Use an app.config like this (when you use 15 "Add Service Reference" from Visual Studio, VS 14 will typically create this for you automatically 13 - and you just need to tweak it to your 12 needs):

<configuration>
    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="UserNameSecurity">
              <security mode="Message">
                <message clientCredentialType="UserName"/>
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8888/MyService" binding="basicHttpBinding"
                bindingConfiguration="UserNameSecurity" contract="IMyService" />
            <endpoint address="net.tcp://localhost:8484/MyService/Mex" 
                      binding="mexTcpBinding"
                      bindingConfiguration="" 
                      contract="IMetadataExchange" name="mexNetTcp" />
        </client>
    </system.serviceModel>
</configuration>

The section and its possible values 11 and subsection are well documented in the 10 WCF configuration.

Alternatively, in VS 2008 9 SP1, you can use the "WCF Service Configuration 8 Editor" - see it in "Tools > WCF Service 7 Configuration Editor".

alt text

It allows you to 6 visually define and modify your client config 5 settings. Once you've launched it from the 4 Tools menu, after that, you can acutally 3 even right-click on the app.config in your 2 Solution Explorer and launch it from there 1 (using that app.config as its basis).

alt text

Marc

More Related questions