We are developing a ReSTful HTTP API with Servicestack(.NET).
Some of the API clients, which have a subset of the actions, demand a service which could be easily added with all the entities, like with the “Add Service Reference” with Visual Studio.
We are thinking about creating a simple asmx web service, but our thoughts on how to do it divide to two:
- The asmx WS will call the ServiceStack service with an HTTP client.
- The asmx WS will reference the same BL that the main service references and will call it directly.
Which is the preffered way?
Is there any other way you would recommend?
If your API has a layer of user facing view/edit models you could put them in a separate assembly and provide your client a simple .NET based driver/bridge/wrapper that uses the same models and invokes your API for them. This way you basically give them what asmx binding code generates for you.
Consider writing adapters for input into your application logic. The application should not have to really know about the clients that access the business logic. Instead you write code that adapts the client’s (in this case your web services) calls into your application into what it needs. This is a basic principle in Allistair Cockburn’s Ports and Adapters Pattern (“Ports and Adapters” or “Hexagonal” Pattern)
The idea behind this principle is to limit the entanglement between the business logic and the interaction with external entities.
The classic Design Patterns book has a description of the generic “Adapters” pattern. Ports-and-adapters uses this pattern.
2