Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Consume a Restful Service in .NET? [closed]

Tags:

rest

c#

.net

What are my options to consume a RESTful service using the .Net framework? When is WCF(using the WebChannelFactory) more preferable to HttpClient?

like image 792
user989046 Avatar asked Jan 16 '12 17:01

user989046


People also ask

How do I consume a RESTful web service?

A more useful way to consume a REST web service is programmatically. To help you with that task, Spring provides a convenient template class called RestTemplate . RestTemplate makes interacting with most RESTful services a one-line incantation. And it can even bind that data to custom domain types.

How do I access REST services?

Step #1 – Enter the URL of the API in the textbox of the tool. Step #2 – Select the HTTP method used for this API (GET, POST, PATCH, etc). Step #3 – Enter any headers if they are required in the Headers textbox. Step #4 – Pass the request body of the API in a key-value pair.

What does it mean to consume a REST service?

Similarly, the act of consuming or using a REST API means to eat it all up. In context, it means to eat it, swallow it, and digest it — leaving any others in the pile exposed.

How do I invoke a REST service?

To use a REST service in Process Designer, you discover the service and select the operations that you want to use. Then, set the server that contains the configuration properties that are required to invoke the service.


3 Answers

Microsoft`s newest HTTP library is here https://www.nuget.org/packages/Microsoft.Net.Http and I have a blog post showing how to use it here.

You would never want to use WebChannelFactory against a RESTful service. The coupling generated by WebChannelFactory defeats the point of REST.

like image 52
Darrel Miller Avatar answered Sep 20 '22 21:09

Darrel Miller


Check out restsharp. I haven't used it, but am looking into it for consuming our own REST services.

like image 45
Rex Morgan Avatar answered Sep 21 '22 21:09

Rex Morgan


The hammock project makes it very easy to consume RESTful services, you can use it to easily create the required http requests you need:

https://github.com/danielcrenna/hammock

like image 42
Bassam Mehanni Avatar answered Sep 19 '22 21:09

Bassam Mehanni