Solved

What steps should I use to implement  HTTP POST of an XML document?

Posted on 2012-12-21
4
291 Views
Last Modified: 2012-12-24
Requirement: We have been given the ability to create Orders by creating an XML document. One of the methods available is "HTTP POST of an XML document".

What steps or tools can I use to create the "HTTP POST of an XML document"?

Thanks
0
Comment
Question by:eeclint
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Gary Davis
ID: 38714882
Well, let's assume your xml is in a file and you are writing a C# DotNET console application.

You can run this application from a command line and pass the filename as the first argument.

The program should read the xml as a string rather than load it into an XDocument since you want to post the xml to a destination url.

The program would then instantiate a WebClient and call the UploadString() method passing the url to the server and the xml string. This will do the post.

Additional details: http://msdn.microsoft.com/en-us/library/ekfaaeay(v=vs.100).aspx

Also, there is an UploadFile() method that may make this even easier since it will read the file for you.

Gary Davis
0
 

Author Comment

by:eeclint
ID: 38714921
Hi Gary,

Thanks for your response.

Are there any sample pieces of code that I can use & then plugin my XML data using the C#  DotNET console application ?

I'm not an expert in C# ?

Thanks again.
0
 
LVL 18

Accepted Solution

by:
Gary Davis earned 500 total points
ID: 38714997
Here is a simple program that uses the filename specified in the 1st argument. You can add error checking like verify there actually is an arg[0] and that the file exists and that the UploadFile() does not trap, etc.

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var xmlFile = args[0]; // File to post
            var webClient = new System.Net.WebClient();
            webClient.UploadFile("http://www.someserver.com/", "POST", xmlFile);
        }
    }
}

Open in new window

0
 

Author Closing Comment

by:eeclint
ID: 38719501
Hi Gary,

Thanks for the code. I'll give it a shot & ask more questions if I get stuck later.

Thanks again.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Merge 2 XML Files together 5 55
Transform XML to Excel using XSL 1 35
XSLT XML 4 28
XML XSL Message 3 31
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question