I have been looking all over trying to find a simple example of how this is done... Basically I want to send info from a form to another website API via XML and get the information they send back to me.

If anyone has any examples or knows of any sites that explain it clearly please let me know.

I am trying to write it in C# .NET 2.0...

Does anyone know how to get the action and version parts into a node? Here is an example:

<Shipment action="RateEstimate" version="1.0">

I figured that part of it out...

shipCredentials.SetAttribute("action", "RateEstimate");

Now that I have everything writing to a XMLdocument (XMLDocument doc = new XMLDocument()... Does anyone know how to send it to the server and get a response?

Here is what I used to get this to work...

Uri Site = new Uri("http://addressofsite");
                WebRequest request = WebRequest.Create(Site);
                request.Method = "POST";
                String postData = doc.OuterXml.ToString();
                byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType = "application/x-www-form-urlencoded";
                request.ContentLength = byteArray.Length;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();

                WebResponse response = request.GetResponse();
                dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                string responseFromServer = reader.ReadToEnd();
                tbResponse.Text += responseFromServer + "\n";
                //Xml Outputter = responseFromServer;
                reader.Close();
                dataStream.Close();
                response.Close();

                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(responseFromServer);

If anyone know of any easier way to do it, please let me know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.