Saturday, May 25, 2013

using wsHttpBinding endpoint with transport security for a WCF Service in asp.net

hi in this post i will show how to use wsHttpBinding endpoint  with transport security for a WCF Service in Asp.net.

Go to the webconfig file of the WCF application:

1. After defining the implementation of the methods which are going to be exposed by the service, we will go to the web.config file here will define the service behavior, endpoint(wsHttpBinding) and transport security.


<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    
    <bindings>
      <wsHttpBinding>
        <binding name="SecurityByTransport">
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


    <services>
      <service behaviorConfiguration="ServiceBehavior" name="WcfService5.Service1">
        <endpoint binding="wsHttpBinding" contract="WcfService5.IService1"/>
        <endpoint address="mex" binding="mexHttpBinding"
              name="MetadataBinding" contract="IMetadataExchange"/>
      </service>

    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

2. Run the project to check the desired output

1



2

No comments:

Post a Comment