1

We currently have an application (Client/Server) that communicates through WCF. We would like to move away from the WCF approach and use a REST approach instead.

There are a few reasons for this, such as overhead (in terms of size) and the possibility to use the same access method for both our Windows client (currently a WinForm client) and mobile devices. We are also sometimes running the server on the Mono framework, and even though we have it up and running, we have seen some differences regarding how WCF is working on the Mono stack compared to the .NET Framework (so I would not like to use the WebHTTPBinding in WCF to handle REST).

The service also needs to be self-hosted (i.e. not in IIS).

The problem when shifting from WCF to other alternatives is related to contracts. I would like to make it possible to unit test the REST calls, and I would like a contract to be involved, enabling the clients to use proxy classes that they do not have to create by themselves - pretty much like WSDL.

The main idea for handing out proxy classes to developers is that the clients should be able to rely on the service provider to get the correct proxy classes and that they should not need to care about the URLs used.

Is there any way this could be done automatically, and if so - using what framework or method? Having looked brifely at WebAPI, I came across an example of generating a proxy (http://www.codeproject.com/Tips/535260/Proxy-Object-Generation-for-MVC-and-WebAPI-Control). This would simplify for the developers, but would mean that I manually need to create the proxy for the developers to use.

Any suggestions would be appreciated :)

ForestC
  • 213
  • 1
  • 12

1 Answers1

0

For Client side unit tests, you should create mock for your rest service responses.

Otherwise You can create a static mock page with all of your service responses.

Usama Khalil
  • 436
  • 1
  • 4
  • 14
  • Mocking on the client side is no problem, but I still need to handle the generation of proxy classes in an easy way (not manual, if possible). – ForestC Apr 18 '14 at 04:44
  • You should not look for Proxy classes at all. You should use JSON.NET library to covert the Mock Json string response data to use in ur client code. Your client developers should not be using any model of the server. Follow REST design guidelines. which will end up as a simple resource available through URL. – Usama Khalil Apr 18 '14 at 06:45
  • 1
    I know that this doesn't really apply with the standard approach but my wish is to make it possible to swap the current implementation of the WCF to a new REST approach without requiring the clients to rewrite all code that access the services. There are many, many methods or calls involved and by providing the clients a method that does not cause them very much pain to switch to, the switch will be much easier, hence the idea with generating proxy stuff for the clients. – ForestC Apr 18 '14 at 11:01