When I run the following code, the rental web service receiving the request is empty body (content length = 0) and Do not know why I don?
If I execute the requisite request during the debugging of the request and the server receives the body, then I think I am not configuring anything for any idea of the request?
var request = (HttpWebRequest) WebRequest.Create (Yuri); Request.ContentType = "text / xml"; request. Method = "post"; Request.CookieContainer = New Cookie Container (); Request.CookieContainer.Add (Yuri, New Cookie ("SSotoken", HttpUtility.UrlEncode (SsoToken)); Request.ContentLength = data.Length; Request.BeginGetRequestStream (ar1 = & gt; {byte = encoding. UTF8.GetBytes (data); var stream = request.endimatequestionstream (AR1); stream; write (byte, 0, data. Length); close the stream ( ); Request.BeginGetResponse (ar2 = & gt; Handle search complete (ar2, request, action), state);}, state);
The first thing to do is to fix the bug in the code. The code assumes that the total number of bytes to be sent will be the number of characters in the data string. This is not true if the original ASCII characters in the string are characters outside of the character set.
You should first get the UTF8 byte array and use the length of this array as ContentLength and make sure that you send the entire array.
Comments
Post a Comment