Last post Oct 16, 2009 05:24 AM by kashifmunir
Jun 22, 2009 11:02 AM|kashifmunir|LINK
I am new to ASP.NET 3.5. Havent really had the time to study WCF and its REST capabilities. In one of my projects, I have to communicate to a 3rd party REST based services. I do have the XML structure that I should pass to the REST service and some sample
responses that I may receive from the REST based service but I do not know how to do it using .NET 3.5. Can anyone provide a simple example to atleast get me started. Will be really grateful if some code can also be provided in this regard.
Jun 24, 2009 08:22 AMfirstname.lastname@example.org|LINK
Here is a way. First install REST Starter Kit Preview 2 and reference your project to Microsoft.Http.dll and Microsoft.Http.Extensions.dll
string baseAddress = "http://exmaple.com/Service.svc/"; // Service Base Address
string path="exposedUriTemplate"; //the Exposed UriTemplate for your interface
HttpClient client = new HttpClient(baseAddress);
HttpResponseMessage message = null;
//use HttpContentExtensions to create Http Content, can also use HttpContent class
HttpContent content=HttpContentExtensions.CreateDataContract<T>(T item);
//do Http Request and get the response
message = client.Post(path, content);
//other requests : client.Get(path); client.Put(path, content); client.Delete(path)
Hope it can help.
Oct 16, 2009 05:24 AM|kashifmunir|LINK
Thanks for your response but I did it the easier way. I have used HttpWebRequest and HttpWebResponse to generate requests post it and receive response. This is a far easier way of doing it as it does not require any knowledge of REST starter kit. Although
you have to generate the XML request and read the response but it is not that difficult.