Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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:

  1. The asmx WS will call the ServiceStack service with an HTTP client.
  2. 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?

share|improve this question
add comment

2 Answers

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.

share|improve this answer
add comment

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.

share|improve this answer
    
So are you suggesting the 2nd approach? –  Mithir Mar 8 '13 at 15:59
1  
Yes, if you understand that the business logic should not be duplicated simply in order to allow the two services to interact with it. However, your BL should not have specific implementation details for each client service using it. Instead, I recommend you create a single API. You then create adapters that will adapt each web services' requests to the API. This will also give you long-term flexibility as you could later add additional adapters for mobile, other services, etc. without affecting the application layer directly. –  MauMen Mar 8 '13 at 16:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.