0

I have a web service that return an xml file. Now I want to create a new web service that uses a part of information that contains the output of first web service. My question is what is better solution:

1.call first web service and use result in new web service?

  1. recreate a part of code of first web service and create an new web service which is independent from first.

I know with first solution I can handle better the code but maybe it will be slower and use more traffic in network. Οn the other hand,the second proposal solution don't reuse code and it will be more difficult to conserve the project. I would like an complete answer using arguments.

Thank you

Jimmysnn
  • 583
  • 4
  • 8
  • 30
  • 1
    You could just reuse code from the first WS in the second WS by moving it in a separate (shared) module/lib. Utilizing an output of the first WS in the second WS not only increase the response time, but also dramatically increase complexity of your second WS. – Ivan Oct 15 '14 at 17:44
  • So you propose me to create a lib with first web service? ? please I want an answer with arguments. what practice is better and why. – Jimmysnn Oct 15 '14 at 17:51

3 Answers3

1

Experts advice to avoid the 'remote' solutions for as long as possible, as they brings complexity in testing, debugging, maintaining, etc. Just imagine, how would you handle situation when the first WS is going down? How would you test all this? How would you handle situation when the first WS reponds with some invalid data? Lots of questions arises here.

It is really hard to give you the 'right' answer, because it always depends on context and your needs. Sometimes there is just no choice, but implementing the distributed solution.

For inspiration, I would strongly recommend reading the "Enterprise Architecture Patterns" book of M. Fowler.

Ivan
  • 837
  • 6
  • 15
1

Each has its own pros and cons. I'm trying to describe them below:

  1. Using the service has the advantage of not engineering (Dev and Qa) the same functionality twice. You can call a remote service, and just use the functionality it provides. That's why services exist, isn't it? Also, when the service gets evolved, you do not have to worry about anything, like changing your local jar, etc. However, the service runs as a separate component. It thus needs to be monitored and operationally managed.
  2. Using a jar/library in place of a service has the advantage of "locality". The code being executed within the process is much high performing. You can avoid creating a socket connection, and dealing with complexities of calling another service. However, you might have to abstract out the function as a library.

It altogether depends on "what" functionality you are looking at, how complex is it to implement, will the functionality frequently evolve, and would it be useful for other set of clients? If it's complex, evolving, and useful to a multitude of clients, the answer is "write a service".

Manish Maheshwari
  • 4,045
  • 2
  • 15
  • 25
0

Diplomatic Question. Its depends on organization to organization , strategy, architecture and design you have followed.

My Suggestion is :

Go with Option 1: That is divide and rule, if it is service oriented architecture with many consumers for your service

Go with Option 2: If you are the consumer and provider for this service.

Sireesh Yarlagadda
  • 12,978
  • 3
  • 74
  • 76
  • web service 1 created for clients. Also the web service 2 (we will create it now) can be a client for wb1 and produce an new service. So what is your opinion? – Jimmysnn Oct 15 '14 at 23:15
  • Maintain two separate WS calls.(make sure a relation exists between this two calls to form as one result). – Sireesh Yarlagadda Oct 16 '14 at 02:53