webservice & https & verisign

HTTPS = WebService + SSL verisign

  • Step 1. Install Server Certificates on the Web Server
  • Step 2. Create a Web Service 😛
  • Step 3. Configure the Web Service Virtual Directory to Require SSL
  • Step 4. Test the Web Service Using a Browser
  • Step 5. Install the Certificate Authority’s Certificate on the Client Computer
  • Step 6. Develop a Web Application to Call the Serviced Component

Step 1. Install Server Certificates on the Web Serverin IIS right click on Default Web Site & goto Directory Security tab then click on Server Certificate button then follow the wizard and that wizard will generate a base64 coded information in text file which u will have to forward to CA (Certificate Authority) in my case CA is VeriSign, CA will return you encrypted information which you have to save as any-name.cer and start that wizard again and select first option by name like process pending …. then follow the wizard and provide it that encrypted information which u got in response of your information from your CA after completion of wizard click on Edit button in Directory Security tab under Secure Communication section and check the Require Secure Channel (SSL) 🙂

Step 2. Create a Web Service

To create a simple Web service on the Web service host computer

  1. Start Visual Studio .NET and create a new C# ASP.NET Web Service application called SecureMath.
  2. Rename service1.asmx as math.asmx.
  3. Open math.asmx.cs and rename the Service1 class as math.
  4. Add the following Web method to the math class.
    [WebMethod]
    public long Add(long operand1, long operand2)
    {
      return (operand1 + operand2);
    }
  5. To create the Web service, click Build Solution on the Build menu.

Step 3. Configure the Web Service Virtual Directory to Require SSL

in IIS right click on your web service’s (in our case Secure Math) virtual directory and goto Directory Security tab and then under Secure Communication Section click on Edit button and then check Require Secure Channel (SSL) if unchecked;)

Step 4. Test the Web Service Using a Browser

https://WebServer/securemath/math.asmx

Step 5. Install the Certificate Authority’s Certificate on the Client Computer

launch Internet Explorer expand Tools menu and click on Internet Options then select Content tab then Certificate button and then Import that file which your CA send you and which you store as any-name.cer 😛

Step 6. Develop a Web Application to Call the Serviced Component

  1. On the Web service client computer, create a new C# ASP.NET Web application called SecureMathClient.
  2. Add a Web reference (by using HTTPS) to the Web service.
    1. Right-click the References node within Solution Explorer, and then click Add Web Reference.
    2. In the Add Web Reference dialog box, enter the URL of your Web service. Make sure you use an HTTPS URL.

      Note If you have already set a Web reference to a Web service without using HTTPS, you can manually edit the generated proxy class file and change the line of code that sets the Url property from an HTTP URL to an HTTPS URL.

    3. Click Add Reference.
  3. Open WebForm1.aspx.cs and add the following using statement beneath the existing using statements.
    using SecureMathClient.WebReference1;
  4. View WebForm1.aspx in Designer mode and create a form like the one illustrated in Figure 2 using the following IDs:
    • operand1
    • operand2
    • result
    • add

    Figure 2. WebForm1.aspx form

  5. Double-click the Add button to create a button-click event hander.
  6. Add the following code to the event handler.
    private void add_Click(object sender, System.EventArgs e)
    {
      math mathService = new math();
      int addResult = (int) mathService.Add( Int32.Parse(operand1.Text),
                                          Int32.Parse(operand2.Text));
      result.Text = addResult.ToString();
    }
  7. On the Build menu, click Build Solution.
  8. Run the application. Enter two numbers to add, and then click the Add button.The Web application will call the Web service using SSL.

bassssss itna sa kaam tha 😀 khusssh avain parayshaan ho rahay thay tupid 😛

oa comment zaroor pass karna for my improvements plz 🙂 waisa sudharna ma nay tu ha nahi tum jitna marzi comment day k zoooor laga loooooo 😛

4 responses to “webservice & https & verisign

  1. Administrare server

  2. Dear Muhammad Adnan

    I found your blog when trying to find a solution for connecting to an https web service from desktop vc++ application. My application uses ATL library without .NET framework. Is there any way for connecting to an https web service?

    Thanks

  3. hi Ahmadi,

    I tried this in a Mobile application.
    Whenever i call this webservice, its not showing that Security Window. after sometime it shows a Error “The Remote Name could not be resolved”. I learned that the Windows Mobile won’t be able to show that Security Window and tat’s why we are getting error. but am not able to find a solution for this.

    Help Karo na Bhai.. Bhaut Tension Hai 🙂

    Cheers
    Biju

Leave a comment