Best way to use external SOAP API?

I am developing a Rails application that will need frequent access to public APIs, and I'm not sure if the best way to host external APIs (SOAP / WSDL) in a Rails application is, how about a model, how can we manage what? Any ideas, comments?

+4
source share
2 answers

Current rivals for the β€œbest” library for consuming external SOAP services look like Savon or Handsoap . There is a comparison between here

I cannot comment on handsoap since I have not used it, I am pleased with Savon, which works well for me.

In terms of application structure, I would create a folder under lib for the interface with the name after the external object, and then save the files there using the namespacing rails functions.

So, an example, I have an external interface for a Sentinel system. So I have RAILS_ROOT / lib / sentinel, and then all classes inside this folder are declared in the Sentinel module.

+3
source

The first thing to do is to see if there are any gems for the API you want to interact with. Write a small gem wrapper class or just turn it on and use it where you need it.

If you want to talk with the REST service, I would suggest the rest of the client’s stone. If you want to do something completely custom, you can use Jon Nunemaker HTTParty. Nokogiri, an XML parser gem, is also useful for using XML-based services.

+1
source

Source: https://habr.com/ru/post/1308318/


All Articles