Question

This is not a subject I am strong in so I apologize ahead of time if I say something ridiculous.

I have developed an HTTP service using Mule. I have it functioning perfectly when I connect directly to the service and send data using a test harness I wrote in C#.

As the final part of my testing, I need to send it to an HTTPS URL that is supposed to "decrypt" the message and forward it to my service. When I send a message to the HTTPS URL, it gets forwarded to my service but the message contents appear empty and therefore does not get processed. I understand that I may have to add some "encryption" to my Test Harness but I have been researching how to do this all day and nothing I have found is answering my question.

Here is an example of the code I am using for the simple HTTP request:

        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["HttpDestination"].ToString());

        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = data.Length;

        using (Stream strm = req.GetRequestStream())
        {
            strm.Write(data, 0, data.Length);
        }

        HttpWebResponse response = (HttpWebResponse)req.GetResponse();

What do I need to change here to make this work?

Was it helpful?

Solution

Here is the solution that I discovered here. I needed to add the following line:

req.ProtocolVersion = System.Net.HttpVersion.Version10;

Without this, a timeout was occurring when getting the request stream and the content was never being sent, only the headers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top