Only Bolivian Here
Only Bolivian Here

Reputation: 36773

How do I encrypyt a response/request to a WebService ASMX?

Here's my little web service demo:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)] 
public class ServicePrueba : System.Web.Services.WebService
{
    [WebMethod(EnableSession=true)]
    public int SayHello()
    {
        int counter;
        if (Context.Session == null)
        {
            counter = 1;
        }
        else
        {
            int tmpCounter = Convert.ToInt32(Context.Session["Counter"]);
            counter = tmpCounter + 1;
        }

        Context.Session["Counter"] = counter;
        return counter;
    }
}

And here's how I invoke it via a Console client application:

class Program
{
    static void Main(string[] args)
    {
        ServicePrueba serviceProxy = new ServicePrueba();

        /*Set the cookie container on the proxy.*/
        var cookies = new System.Net.CookieContainer();
        serviceProxy.CookieContainer = cookies;

        Console.WriteLine(serviceProxy.SayHello());
        Console.ReadKey();

        Console.WriteLine(serviceProxy.SayHello());
        Console.ReadKey();

        Console.WriteLine(serviceProxy.SayHello());
        Console.ReadKey();

        Console.WriteLine(serviceProxy.SayHello());
        Console.ReadKey();

        Console.WriteLine(serviceProxy.SayHello());
        Console.ReadKey();

        Console.ReadKey(true);
    }
}

My question is, the information that coming and going through the wire is in plain text no? (Is there a way to see what this data look like?)

How can I protect this sensitive information from prying eyes? I want to simply encrypt the message so it's gibberish when it's through the wire.

Upvotes: 1

Views: 183

Answers (2)

willthiswork89
willthiswork89

Reputation: 174

You can see the traffic via a packet sniffing tool like http://www.wireshark.org/download.html to analyze the packets. I'm pretty positive its not very useful .

Upvotes: 0

McKay
McKay

Reputation: 12624

You should use HTTPS. Hosting it over an HTTPS connection will solve this issue.

Upvotes: 3

Related Questions