Solved

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

Posted on 2012-12-21
4
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Trouble parsing soap xml result 3 74
XSLT Help 12 37
Powershell Regex Replace Question 5 43
SQL Server XML Select sub tables 4 67
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…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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