Wednesday, 8 August 2012

WCF Config file setting

Metadata publishing Option:

Service web.config file has option to publish metadata in <System.ServiceModel> tag
<behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviorConfiguration">
          <serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="false" includeExceptionDetailInFaults="false" />
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

User principal setting for WCF consumer client: 

When we consume the WCF service, it will default add the current user credential as User Principal, but we can change that from App.Config file. After changing the User principal the service should respond as required.
Default UserPricipal :
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITwoWayAsync1"
                contract="proxySchemaNameProcess.BTServiceExpose_NameProcess"
                name="WSHttpBinding_ITwoWayAsync1">
                 <identity>
                    <userPrincipalName value="mydefaultuser" />
                </identity>
            </endpoint>

Changed UserPricipal setting: used my current user
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITwoWayAsync1"
                contract="proxySchemaNameProcess.BTServiceExpose_NameProcess"
                name="WSHttpBinding_ITwoWayAsync1">
                 <identity>
                    <userPrincipalName value="CurrentUser" />
                </identity>
            </endpoint>

No comments:

Post a Comment