How to secure a Silverlight-Enabled WCF Web Service with SSL?

后端 未结 4 1789
心在旅途
心在旅途 2021-02-03 14:09

How do you secure a Silverlight-Enabled WCF Web Service with SSL? I have tried setting it up similar to a regular WCF service secured by SSL, but it doesn\'t seem to work. Wha

4条回答
  •  心在旅途
    2021-02-03 14:28

    To create Silverlight-Enabled WCF Web Service using SSL you have to do the following steps:

    1. Create standard Silverlight-Enabled WCF Web Service using Visual Studio 2010
    2. Change 3 places of webconfig.xml:

      a. In serviceMetadata change httpGetEnabled to httpsGetEnabled like this:

      
         
           
            
            
          
        
      
      

      b. In binding change httpTransport to httpsTransport:

      
        
          
            
            
          
        
      
      

      c. in endpoint change binding="mexHttpBinding" to binding="mexHttpsBinding":

      
        
        
      
      
    3. Don't use ServiceReferences.ClientConfig. Create everything in code behind - it's easy to deploy on server:

      CustomBinding binding = new CustomBinding(new BinaryMessageEncodingBindingElement(), new HttpsTransportBindingElement());         
      YourServiceReference.YourServiceClient service = new YourServiceReference.YourServiceClient (binding, new EndpointAddress(new Uri( "https:yourhostname/YourService.svc").AbsoluteUri));        
      service.YourMethodCompleted += new EventHandler(service_YourMethodCompleted );
      service.YourMethodAsync();
      

提交回复
热议问题