5

I am designing the back-end to a SOAP web-service and have a question about how I am thinking of doing it.

I am going to go with a simple layered design which consists of 3 separate layers.

Layer 1 -> Layer 2 -> Layer 3

Layer 1 : Will implement the SOAP skeleton interface, so this will be the main entry point of my application. This layer will pull data from the SOAP request and pass it to the business logic layer as a business object. It will get back business objects from the business logic layer with which it will populate a SOAP response.

Layer 2 : Business logic layer that implements the business logic behind the web-service. It will be passed data from Layer 1 and interact with Layer 3, the DAO layer.

Layer 3 : DAO layer which will preform CRUD operations on my DB.

With populating SOAP response objects in my code, the implementation might be a bit messy in Layer 1, so I came up with the following 3 options.

Option 1 - Three layers is enough, any more layers would be overkill. SOAP objects are always going to be messy looking, just get over it.

Option 2 - Create an extra layer between Layers 1 and 2. This layer would take data from the SOAP request, populate a business object which it would then pass to the business logic layer. This would keep the methods in Layer 1 neat and tidy. It would look something like this :

Layer 1  ->  SOAP Request   ->  Layer 1.A  ->  Business Object  ->  Layer 2
Layer 1  <-  SOAP Response  <-  Layer 1.A  <-  Business Object  <-  Layer 2   

Option 3 - Do not create any more layers. Simply create a utility object with a method that takes a SOAP request and returns a business object. I could then pass the business object to Layer 2. The same utility object could then be used in Layer 2 to pass a SOAP response back to Layer 1. Or does this approach kind of blur the lines and make my design less modular?

1 Answer 1

2

It depends on what you might potentially share layer 2 with. If most of your back end systems operate on business objects, it makes much more sense to have the data converted to a business object before passing it off to your other systems. Both conversion and simple pass-through will work, but in the absence of any strict requirements I would suggest whichever is more conceptually local to your current systems. This is primarily for maintainability reasons.

Including an extra layer depends on if you expect to include multiple operations/endpoints on a single call. The extra layer decouples the SOAP request from the operations, allowing flexible mix/match and request dispatch based on identification without putting that in the web service layer. It can be very useful if you can't treat all requests the same, for whatever reason(different source, load balancing, etc.). If you don't expect that at all, you should be fine to design for the limited per-call case and nix the extra layer.

In either case, I would recommend making the transformation process into a utility object. It doesn't 'cost' you very much, and I find/use our front-end to xml utility all over the place. (We have a plethora of front end formats/channels we accept on, but consolidate to a single xml format for use internally.)

1
  • "We have a plethora of front end formats/channels we accept on, but consolidate to a single xml format for use internally" - yeah, in essence that's it. I could not agree more. @T-Pane: Plan for change, especially when you start with bloaty SOAP. Here's how to do it.
    – JensG
    Mar 27, 2014 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.