Question HTTP POST with callback

LiteIce

New member
Joined
Dec 20, 2017
Messages
1
Programming Experience
5-10
Hi guys, I wonder if you could please help me? Do any of you perhaps know of a way to setup a callback on an HTTP POST? I can get the response from the POST no problem, but it is a requirement on a project that I am working on that I should setup a callback to receive additional data as well.


Here is a snippet of the c# code I have in place:


...

C#:
httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);


//Set HttpWebRequest properties
byte[] bytes;
bytes = Encoding.ASCII.GetBytes(xmlString);
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/xml; encoding='utf-8'";


//Get stream object
requestStream = httpWebRequest.GetRequestStream();


//Writes a sequence of bytes to the current stream
requestStream.Write(bytes, 0, bytes.Length);


//Close stream
requestStream.Close();


//Sends the HttpWebRequest and wait for its response
httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse;


if (httpWebResponse.StatusCode == HttpStatusCode.OK)
{
    //Get response stream
    responseStream = httpWebResponse.GetResponseStream();


   //Obviously from here we can get the response etc..      
}


//Close HttpWebResponse, 
httpWebResponse.Close();

Any help would be greatly appreciated!
 
Back
Top Bottom