sending data to another server

Discussion in 'ASP .Net' started by pintu, Dec 14, 2006.

  1. pintu

    pintu Guest

    Hi friends..
    am having one problem while reading an xml file and sending the
    contents by HTTP POST to another server..but i am facing the error like


    ->Cannot send a content-body with this verb-type.<?xml version="1.0"
    encoding="utf-8"?>

    am mentioning the code below..

    WebRequest webreq;
    WebResponse webres;
    webreq =
    WebRequest.Create("http://localhost/test/Testupload/testxml.xml");

    webres = webreq.GetResponse();
    StreamReader sReader = new
    StreamReader(webres.GetResponseStream());
    string strData = sReader.ReadToEnd();
    webres.Close();

    //Post data
    string querystring = strData.ToString();
    webreq.ContentType = "multipart/form-data";
    webreq.Method = "POST";
    Stream strNewStream = webreq.GetRequestStream();
    byte[] temp_byteArray;
    temp_byteArray =(new
    UnicodeEncoding()).GetBytes(querystring);
    strNewStream.Write(temp_byteArray, 0,
    temp_byteArray.Length);
    strNewStream.Close();
    HttpContext.Current.Response.Write(querystring);

    Kindly help me in solving the problem..In case am wrong in the above
    code then plz mention the correct way to solve the problem as soon as
    possible..


    Regards
    Priyabrata
     
    pintu, Dec 14, 2006
    #1
    1. Advertising

  2. pintu

    imonline Guest

    Hi, Pintu,
    Try using the content type=text/xml
    Thanks,
    Nis
    pintu wrote:
    > Hi friends..
    > am having one problem while reading an xml file and sending the
    > contents by HTTP POST to another server..but i am facing the error like
    >
    >
    > ->Cannot send a content-body with this verb-type.<?xml version="1.0"
    > encoding="utf-8"?>
    >
    > am mentioning the code below..
    >
    > WebRequest webreq;
    > WebResponse webres;
    > webreq =
    > WebRequest.Create("http://localhost/test/Testupload/testxml.xml");
    >
    > webres = webreq.GetResponse();
    > StreamReader sReader = new
    > StreamReader(webres.GetResponseStream());
    > string strData = sReader.ReadToEnd();
    > webres.Close();
    >
    > //Post data
    > string querystring = strData.ToString();
    > webreq.ContentType = "multipart/form-data";
    > webreq.Method = "POST";
    > Stream strNewStream = webreq.GetRequestStream();
    > byte[] temp_byteArray;
    > temp_byteArray =(new
    > UnicodeEncoding()).GetBytes(querystring);
    > strNewStream.Write(temp_byteArray, 0,
    > temp_byteArray.Length);
    > strNewStream.Close();
    > HttpContext.Current.Response.Write(querystring);
    >
    > Kindly help me in solving the problem..In case am wrong in the above
    > code then plz mention the correct way to solve the problem as soon as
    > possible..
    >
    >
    > Regards
    > Priyabrata
     
    imonline, Dec 14, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mark
    Replies:
    1
    Views:
    382
    Simon Gorski
    Mar 2, 2004
  2. Tamer Ibrahim

    Sending data from form to another

    Tamer Ibrahim, Nov 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    386
    Patrick.O.Ige
    Nov 5, 2005
  3. pintu

    sending data to another server

    pintu, Dec 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    300
    pintu
    Dec 14, 2006
  4. Luke
    Replies:
    2
    Views:
    4,726
    Nigel Wade
    Mar 15, 2007
  5. pintu
    Replies:
    0
    Views:
    205
    pintu
    Dec 14, 2006
Loading...

Share This Page