Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:14:04+00:00 2026-06-07T15:14:04+00:00

I have been doing some Google searches and only getting partial successful on this

  • 0

I have been doing some Google searches and only getting partial successful on this topic. I was wondering if someone could suggest an example of doing an HTTP POST using C# to send XML to HTTP service.

I have a asmx web service that extracts data from database and I save that data to XML document. Now I have to send that XML document using SOAP protocol to HTTP service.

I have this part of code for connectig to service

WebRequest myReq = WebRequest.Create("https://WEB_URL");
 System.Net.ServicePointManager.CertificatePolicy = new CertificatePolicyClass();

                string username = "SOMETHING";
                string password = "ELSE";
                string usernamePassword = username + ":" + password;
                CredentialCache mycache = new CredentialCache();
                mycache.Add(new Uri("https://WEB_URL"), "Basic", new  NetworkCredential(username, password));
                myReq.Credentials = mycache;
                myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));

                WebResponse wr = myReq.GetResponse();
                Stream receiveStream = wr.GetResponseStream();
                StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
                string content = reader.ReadToEnd();

So does anybody have a code to send XML document to http service, this part I don’t know how to write, I don’t know am I on the write trace, I belive it has to go somethig like this

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

So plese can somebody help me! THANKS!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:14:06+00:00Added an answer on June 7, 2026 at 3:14 pm

    Here is something I get, hope it’s useful to you:

    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("https://WEB_URL");
    myReq.Method = "POST";
    myReq.ContentType = "text/xml";
    myReq.Timeout = 30000;
    myReq.Headers.Add("SOAPAction", ":\"#save\"");
    
    byte[] PostData = Encoding.UTF8.GetBytes(xmlDocument);
    myReq.ContentLength = PostData.Length;
    
    using (Stream requestStream = myReq.GetRequestStream())
    {
        requestStream.Write(PostData, 0, PostData.Length);
    }
    
    HttpWebResponse response = (HttpWebResponse)myReq.GetResponse();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been doing some research into getting my UTF8 to print correctly.
I have been doing some research on test driven development and find it pretty
I have been doing some research for using MSMQ. Following 2 gave me fundamental
I have been doing some x86 programming in Windows with NASM and I have
Right, bit of a strange question; I have been doing some linq to XML
I recently put up a site and I have been doing some SEO. However
I was doing some stuff with palindromes: This number 9966006699 has been giving me
I have been doing some testing whilst using Jquery UI datepicker and have found
I have been looking all over google to find some answers to my questions
I have done a search in google and been told this is impossible as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.