.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Code Snippets >> Web Services >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Passing Of XML string through HTTPWebRequest,[Post Method] BizTalk.dll

Posted By:Pravin       Posted Date: March 27, 2012    Points: 40    Category: Web Services    URL: http://www.dotnetspark.com  

Here i passing an XML string to Biztalk Location and getting of the web response again as an XML string.

// Pass the URL and XML strings in the Below PostXml function :\

    public void PostXml(string url, string xml)
            byte[] bytes = Encoding.UTF8.GetBytes(xml);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.ContentLength = bytes.Length;
            request.ContentType = "text/xml";
            using (Stream requestStream = request.GetRequestStream())
                requestStream.Write(bytes, 0, bytes.Length);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream resStream = response.GetResponseStream();
            StreamReader rdStreamRdr = new StreamReader(resStream);
            if (response.StatusCode != HttpStatusCode.OK)
                string message = String.Format("POST failed. Received HTTP {0}",
                throw new ApplicationException(message);
                string message = rdStreamRdr.ReadToEnd();//String.Format("POST Successfull. Received HTTP Status{0}",response.StatusCode);           
                TextBox1.Text = message;
        catch (Exception)


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend