Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Win2003 IIS6 C# ASP.NET VB.NET , +
Dear Developer,
 
I am trying to request to Java Server Socket but they are unable to receive my data_string (data="ABC").
 
They receive with error....
"java.io.StreamCorruptedException: invalid stream header: 56455249"
 
my code is as below...
string url = "http://www.myserverurl.com";
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                string proxy = null;
 
                string data = "ABC";
                byte[] buffer = Encoding.UTF8.GetBytes(data);
 
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = buffer.Length;
                req.Proxy = new WebProxy(proxy, true);
                req.CookieContainer = new CookieContainer();
 
                Stream reqst = req.GetRequestStream(); // add form data to request stream 
                reqst.Write(buffer, 0, buffer.Length);
                reqst.Flush();
                reqst.Close();
 
I require Stream obj to send data to server as string and not as byte. How to do so?
 
Thanks in advance.
 
Regards,
Rajesh Katare
Posted 24-Jun-11 5:35am
Edited 24-Jun-11 5:58am
(no name)139.4K
v3

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

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100