Solved

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

Posted on 2012-12-21
4
289 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now