Labels

Monday, June 11, 2007

Generating XML Http Request

Public static GetResponse()

{

            Stream responseStream = new MemoryStream();

            searchRequestXML = new XmlDocument();

            searchRequestXML = CreateTyreSearchRequest(..);

            responseStream = GetResponseStream(uri, searchRequestXML);

            XmlTextReader xmlTextReader = new XmlTextReader(responseStream);

            while (xmlTextReader.Read())

            {  }

}

 

 

public static Stream GetResponseStream(string url, XmlDocument searchRequestXML)

        {

            Stream responseStream = null;

            try

            {               

                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);

                NetworkCredential nc = new NetworkCredential("tyrelink", "tyrelink");

                webRequest.Credentials = nc;

                webRequest.KeepAlive = false;

                webRequest.Headers.Add("SOAPAction", "\"\"");

                webRequest.ContentType = "text/xml;charset=\"utf-8\"";

                webRequest.Accept = "text/xml";

                webRequest.Method = "POST";

                Stream webRequestStream = webRequest.GetRequestStream();

                searchRequestXML.Save(webRequestStream);

                webRequestStream.Close();

                //XmlTextWriter t = new XmlTextWriter(AccessViolationException, null);

 

                WebResponse response = webRequest.GetResponse();

                responseStream = response.GetResponseStream();

 

            }

            finally

            { }

           

          return responseStream;

        }

 

 

 

Thanks & Regards,

Arun Manglick

SMTS || Microsoft Technology Practice || Bridgestone - Tyre Link || Persistent Systems || 3023-6258

 

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Pvt. Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Pvt. Ltd. does not accept any liability for virus infected mails.

No comments:

Post a Comment