Once IIS is configured, we can now proceed to the WCF configuration.
1. Create a binding configuration for the https service by including the following in the serviceModel configuration seciton. This configures the service to enable SSL without requiring the client to be authenticated.
<bindings>
<basicHttpBinding>
<binding name="secureHttpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
3. Finally configure your service to use the behavior and binding configuration.<!-- To avoid disclosing metadata information,<serviceDebug includeExceptionDetailInFaults="true" / </behavior> </serviceBehaviors> </behaviors>
set the value below to false and remove the metadata
endpoint before deployment to production -->
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="true" />
<services>
<service name="SSLSample.Services.ExpenseService"
behaviorConfiguration="DefaultServiceBehavior">
<endpoint name="basicHttpExpenseService" address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpsBinding"
contract="SSLSample.Services.Contracts.IExpenseService" />
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>Take note that the binding for the mex endpoint is using mexHttpsBinding. Deploy the service to IIS and you should be able to run and access the WSDL from https.
</services>
You can use the above configuration for both WCF or Windows Workflow Foundation (WF) service endpoints. If you are using a different binding i.e. wsHttpBinding, make sure you change them appropriately.
[Note: When testing your service using localhost, you may get a warning on your cert or a red address bar on your browser. Use your machine name (append with your domain name - if any) instead]
No comments:
Post a Comment