Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-12-21
4
Medium Priority
?
294 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 2000 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

715 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