0

I am in the planning phase of a project that will use a 3rd party service that supports both REST and SOAP. The SOAP API is more mature and thus supports more operations.

I'd love to depend only on the REST API, but specific use cases have forced the use of the SOAP API. So really there are two options:

  1. Depend ONLY on the SOAP API to do my business logic
  2. Depend on the REST API AND fall back to the SOAP API when necessary

Some opinions on both would be great. And if it is a good idea to consume both in a single application, what are some common best practices and pitfalls?

3 Answers 3

0

Just because an API is written using SOAP doesn't necessarily mean it can't follow REST principles. So this is rather hard to answer without knowing the specific details of the API.

If the REST principles are adhered in the design of the SOAP API, then switching content types should be fairly trivial.

The most important principles here to adhere is the stateless principle. If the API is stateless, then the semantic of each request does not depend on the state of the connection, you would be able to switch between different content types safely.

There are other principles that would make it easier to combine the SOAP and REST API, such as if the SOAP and REST API identified resources in a uniform format, i.e. Uniform Interface principle. These are surmountable if not followed, but makes switching types significantly easier and less fiddly.

1
  • Good points on the stateless-ness of the APIs. As far as I can tell, the SOAP API contract is stateless. The APIs do not follow Uniform Interface principle but I think that is something easily circumvented. Thank you! I was so concerned with the interface of an API, rather than what was the underlying issue.
    – Kevin Le
    Commented Aug 2, 2016 at 4:38
0

Will you ever have direct interaction between data obtained through the REST API and SOAP API? If so you'll be required to create "translation" code for them to be interoperable which might be hard or expensive to do.

If they never interact directly I'd say to use the REST one when you can and fallback otherwise.

Be aware that you'll have to be ready to upgrade when newer capabilities come to the REST API.

0

Look at the likely future roadmap for the APIs (what the vendor's realistically likely to do, not just what they say they have planned). If the SOAP API will be maintained on at least an equal footing with the REST API, using just the SOAP API is a viable option long-term. If however the SOAP API is likely to hit end-of-life and not be maintained, with the REST API being brought up to match and then all new features being only in the REST API, the recommended course would be to use the REST API where possible and treat the SOAP API as a fallback. In the latter case also plan on migrating any usage of the SOAP API over to the REST API at some point to guard against being caught unawares by removal of the SOAP API by the vendor.

Your Answer

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

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