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)141.3K
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 215
1 Sebastiaan Meijerink 141
2 Sergey Alexandrovich Kryukov 124
3 Rana Waqas 85
4 Maciej Los 84
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,288
2 Peter Leow 2,534
3 Abhinav S 2,358
4 Maciej Los 2,352


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2015
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