views:

60

answers:

1

I am very confused on this topic. I have a webservice on another machine. All I need to do is post the xml to the url and return the results to the view. I have not found any working examples of this. Also there seems to be different ways of doing it.

What is the best way to post xml data to a url and display the results in a view?

Thanks

+1  A: 

In the controller you could make a web request. Is this what you are looking for?

byte[] postData;

//set postData

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://another-server/service/");
request.Method = "POST";
request.ContentType="application/x-www-form-urlencoded";
request.ContentLength = postData.Length;

Stream response=request.GetRequestStream();
response.Write(postData,0,postData.Length);
response.Close();
iaimtomisbehave
where is the data for the reply?
Joe
In your response stream. You can read up on it here http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx
iaimtomisbehave