Send XML C#

I need to send an xml document. I got an example how to do this but it is for Apache.
How would I modify this for C#?

string gatewayURL ="http:...";
        string theXML = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
<read>
<voice></voice>
<language></language>
<ip></ip>
<site></site>
<text></text>
</read>";
PostMethod post = new PostMethod(gatewayURL);
RequestEntity entity = new StringRequestEntity(theXML);
post.setRequestEntity(entity);
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try
{
int result = 0;
try
{
result = httpclient.executeMethod(post);
// Display status code
logger.info("Response status code: " + result);
// Display response
logger.info("Response body: "
post.getResponseBodyAsString());
}
catch (IOException ex)
{
logger.error ("Could not contact msg gateway '");
}
}
finally
{
// Release current connection to the connection pool when
done
post.releaseConnection();
}

    }
}
johnkainnAsked:
Who is Participating?
 
cubaman_24Connect With a Mentor Commented:
Hello:
Then maybe this is not the right way to do it..
 It's easier to add a web reference to your project, and call the webservice without using xml directly, instead, use normal object notation.
Find some examples in the following links.
http://www.codeproject.com/KB/webservices/WebServiceConsumer.aspx
http://devpinoy.org/blogs/keithrull/archive/2008/04/08/how-to-consume-web-services-in-asp-net.aspx
Best regards.

0
 
cubaman_24Commented:
Hello:
Could you explain exactly what you're trying to achieve? If you just want to send an xml response to client, the following code should make it.
Best regards.
string xml = SomeMethodReturningXml();
Response.Clear();
Response.ContentType = "text/xml";
Response.Write(xml);

Open in new window

0
 
johnkainnAuthor Commented:
Thank you. Sorry for unclear question.
I would like to write the XML in code behind in C# and then send XML to a webservice.
Then I would like to receive a file and store in a folder.
I am not very familar with XML. I would appreciate your help.
0
All Courses

From novice to tech pro — start learning today.