Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried the code below to get webresponse from the server.
C#
string soap = "my xml file";
HttpWebRequest req =(HttpWebRequest)WebRequest.Create("http://212.170.239.71/appservices/http/FrontendService");
req.ContentType = "text/xml;charset=utf-8";
req.Accept = "text/xml";
req.Method = "POST";
using (Stream stm = req.GetRequestStream())
{
    using (StreamWriter stmw = new StreamWriter(stm))
    {
        stmw.Write(soap);
    }
}

WebResponse response = req.GetResponse();
XmlDocument xDoc = new XmlDocument();
XmlTextReader myXMLReader = null;
myXMLReader = new XmlTextReader(response.GetResponseStream());
string asdfgh = myXMLReader.ReadOuterXml();
xDoc.Load(myXMLReader);

But now the agents of the webservice told me to use Gzip compression to send the request and recieve the response.

I am just clueless to use Gzip compression.
Please help me
Posted
Updated 22-Jun-14 20:55pm
v2
Comments
Kornfeld Eliyahu Peter 23-Jun-14 4:34am    
You may setup IIS to use compression on HTTP...
hrishisinha 23-Jun-14 5:07am    
ya but i have uploaded the code to godaddy server.
I have searched google and have found many examples but actually i am new to c# thats why cant find the right code.
Please help if you can its urjent
Thanks & Regards

1 solution

You can try this.

C#
using (Stream stm = req.GetRequestStream())
{
  using (GZipStream compressionStream = new GZipStream(stm, CompressionMode.Compress))
  {
    byte[] input = ASCIIEncoding.ASCII.GetBytes(soap);
    compressionStream.Write(input, 0, input.Length);
  }
}


And more info can be found here http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.write(v=vs.110).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900