Jeremy Stein - Brain

« »

C# Submit XML

Here is the Main method for a C# program that will send the specified XML file to the given URL:

static void Main(string[] args)
  byte[] fileContents = File.ReadAllBytes(args[0]);

  WebRequest request = WebRequest.Create(args[1]);
  request.Method = "POST";
  request.ContentType = "text/xml";
  request.ContentLength = fileContents.Length;
  Stream postStream = request.GetRequestStream();
  postStream.Write(fileContents, 0, fileContents.Length);

  Console.WriteLine(new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd());

January 11, 2010 No Comments.

No Comments

Be the first to comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?

« »