In my previous blogs I have introduced how to create a WCF service and host it in IIS, and config it over both Http and Https. In this blog I would like to move forward -- config the service work over only HTTPS. I will still use that sample project.
1. Setup Web Application with SSL Required
Open the IIS Manager, Select "ServiceHost" web application under the default web site as shown below.
Double-click "SSL Settings" on the right frame, the "SSL Settings" window is shown as below.
make sure the "Require SSL" check-box is checked and click the "Apply" button on the top-right of the window.
Now the WCF service hosting site is configed to access via HTTPS only.
2. Change the Web.config
At this point if you test the service via https, it will not activate correctly.
The reason is that we have config the service over HTTP and HTTPS, and now HTTP protocol is forbidden. Let's modify the Web.config file. We need to remove the element and the element for Http. The Web.config now looks like such:
<!-- Service Endpoints -->
3. Run the Application From VS2008
The Silverlight client code looks like:
EndpointAddress address = new EndpointAddress("https://yuzhangqi01/ServiceHost/Service1.svc/ssl");
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
proxy = new Service1Client(binding, address);
Press F5 in Vs2008 and test the application, it returns what we expected.
[@more@]来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13651903/viewspace-1033981/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13651903/viewspace-1033981/