Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Webresponse Question

Webresponse Question

Scheduled Pinned Locked Moved C#
questionphpsysadminxml
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve Messer
    wrote on last edited by
    #1

    I am trying to get a second response from a Webrequest. The server that I am talking to works as follows. First here is my code:

    string postData = ""; // filled with xml request data
    
    Uri myUri = new Uri("http://208.XXX.XX.XXX:10224/?ReturnAddress=209.XX.XX.XX/recvpost.php");
    HttpWebRequest h =  (HttpWebRequest)WebRequest.Create(myUri);
    			
    h.Method = "POST";
    h.ContentType="text/xml";
    h.ContentLength=postData.Length;
    
    Stream newStream = h.GetRequestStream();
    newStream.Write(byte1,0,byte1.Length);
    newStream.Close();
    
    WebResponse resp = h.GetResponse();
    
    StreamReader reader = new StreamReader(resp.GetResponseStream());
    
    string str = reader.ReadLine();
    while(str != null)
    {
        Console.WriteLine(str);
        MessageBox.Show( str );
        str = reader.ReadLine();
    }
    
    resp.Close();
    
    1. Send your request, when received the replay "OK" will be sent. 2) Once the server has the request ready it will send the reply. 3) I am receiving the OK but nothing else. How do you get secondary responses?
    G 1 Reply Last reply
    0
    • S Steve Messer

      I am trying to get a second response from a Webrequest. The server that I am talking to works as follows. First here is my code:

      string postData = ""; // filled with xml request data
      
      Uri myUri = new Uri("http://208.XXX.XX.XXX:10224/?ReturnAddress=209.XX.XX.XX/recvpost.php");
      HttpWebRequest h =  (HttpWebRequest)WebRequest.Create(myUri);
      			
      h.Method = "POST";
      h.ContentType="text/xml";
      h.ContentLength=postData.Length;
      
      Stream newStream = h.GetRequestStream();
      newStream.Write(byte1,0,byte1.Length);
      newStream.Close();
      
      WebResponse resp = h.GetResponse();
      
      StreamReader reader = new StreamReader(resp.GetResponseStream());
      
      string str = reader.ReadLine();
      while(str != null)
      {
          Console.WriteLine(str);
          MessageBox.Show( str );
          str = reader.ReadLine();
      }
      
      resp.Close();
      
      1. Send your request, when received the replay "OK" will be sent. 2) Once the server has the request ready it will send the reply. 3) I am receiving the OK but nothing else. How do you get secondary responses?
      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      What do you mean by a second response? Each request can have only one response. --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        What do you mean by a second response? Each request can have only one response. --- b { font-weight: normal; }

        S Offline
        S Offline
        Steve Messer
        wrote on last edited by
        #3

        I was told by the server provider to send a Webrequest with the above mentioned header information. When the server receives the request it will send the OK reply, and then break the connection. When it has the reply ready it will call back on the ip address provided in the Uri and send the file noted in the Uri recvpost.php.Uri myUri = new Uri("http://208.XXX.XX.XXX:10224/?**ReturnAddress=209.XX.XX.XX**/recvpost.php");
        So, I guess I am asking how to I listen for that reply?

        S G 2 Replies Last reply
        0
        • S Steve Messer

          I was told by the server provider to send a Webrequest with the above mentioned header information. When the server receives the request it will send the OK reply, and then break the connection. When it has the reply ready it will call back on the ip address provided in the Uri and send the file noted in the Uri recvpost.php.Uri myUri = new Uri("http://208.XXX.XX.XXX:10224/?**ReturnAddress=209.XX.XX.XX**/recvpost.php");
          So, I guess I am asking how to I listen for that reply?

          S Offline
          S Offline
          seee sharp
          wrote on last edited by
          #4

          Ok you must be receiving as response code.. you have to receive webresponse stream to get the response form the requested uri. - ashish

          S 1 Reply Last reply
          0
          • S seee sharp

            Ok you must be receiving as response code.. you have to receive webresponse stream to get the response form the requested uri. - ashish

            S Offline
            S Offline
            Steve Messer
            wrote on last edited by
            #5

            If you look at my above code snippit isn't that what I am doing?

            WebResponse resp = h.GetResponse();
            StreamReader reader = new StreamReader(resp.GetResponseStream());
            

            If you mean something different could you please clarify?

            1 Reply Last reply
            0
            • S Steve Messer

              I was told by the server provider to send a Webrequest with the above mentioned header information. When the server receives the request it will send the OK reply, and then break the connection. When it has the reply ready it will call back on the ip address provided in the Uri and send the file noted in the Uri recvpost.php.Uri myUri = new Uri("http://208.XXX.XX.XXX:10224/?**ReturnAddress=209.XX.XX.XX**/recvpost.php");
              So, I guess I am asking how to I listen for that reply?

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              Then the data will be sent as a request to the php page. --- b { font-weight: normal; }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups