johnkainn
asked on
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(enti ty);
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try
{
int result = 0;
try
{
result = httpclient.executeMethod(p ost);
// Display status code
logger.info("Response status code: " + result);
// Display response
logger.info("Response body: "
post.getResponseBodyAsStri ng());
}
catch (IOException ex)
{
logger.error ("Could not contact msg gateway '");
}
}
finally
{
// Release current connection to the connection pool when
done
post.releaseConnection();
}
…
}
}
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(enti
// Get HTTP client
HttpClient httpclient = new HttpClient();
// Execute request
try
{
int result = 0;
try
{
result = httpclient.executeMethod(p
// Display status code
logger.info("Response status code: " + result);
// Display response
logger.info("Response body: "
post.getResponseBodyAsStri
}
catch (IOException ex)
{
logger.error ("Could not contact msg gateway '");
}
}
finally
{
// Release current connection to the connection pool when
done
post.releaseConnection();
}
…
}
}
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
Open in new window