RESTful framework alternatives to WCF

2019-05-28 14:48发布

问题:

Looking for alternatives to the WCF REST start kit, ideally OSS frameworks.

Anyone got a list?

Cheers

Ollie

回答1:

OpenRASTA is the most mature



回答2:

ASP.NET MVC is a good alternative when it comes to generating REST XML and JSON feeds.



回答3:

To build a rest architecture in .net you can use GenericHandlers. You can create a GenericHandler that will receive a HTTP message (POST, GET or..) and return a message of the content-type you specify.

For example I create a generic handler on the url:

http://site/getpeople.ashx?gender=female

And call it with the parmeter gender=female, as above the handler will return the following

<people>

<person>...</person>
...
<people>

And the content type would be text/xml.

This is the simplest way to implement REST web services in .NET



回答4:

I also provide ServiceStack, a modern, code-first, DTO-driven, WCF replacement web services framework encouraging code and remote best-practices for creating DRY, high-perfomance, scalable REST web services.

There's no XML config, or code-gen and your one clean C# web service is enabled on all JSON, XML, SOAP, JSV, CSV, HTML endpoints out-of-the-box, automatically. It includes generic sync/async service clients providing a fast, typed, client/server communication gateway end-to-end.

It also includes generic sync/async service clients providing a fast, typed, client/server communication gateway end-to-end.

This is the complete example of all the code needed to create a simple web service, that is automatically without any config, registered and made available on all the web data formats on pre-defined and custom REST-ful routes:

public class Hello {
    public string Name { get; set; }
}

public class HelloResponse {
    public string Result { get; set; }
}

public class HelloService : IService<Hello> {
    public object Execute(Hello request) {
        return new HelloResponse { Result = "Hello, " + request.Name };
    }
}

Above service can be called (without any build-steps/code-gen) in C# with the line below:

var response = client.Send<HelloResponse>(new Hello { Name = "World!" });
Console.WriteLine(response.Result); // => Hello, World

And in jQuery with:

$.getJSON('hello/World!', function(r){ 
    alert(r.Result); 
});