This Rails project is a sample to communicate with 3rd party services that uses XML (RSS type) as their request/response body.
Other XML services (WSDL, SOAP or RDF type) are not covered (or will be added - when necessary) since there are already gems to assist in that area.
There are 3 main parts to the concept.
- Adapter Class
- Service Class
- Schema (Helper Class)
But first, we go through an example flow:
- User details are filled in and submitted
- Once user is successfully created, the controller calls the adapter to submit the request to a 3rd party service's endpoint
The adapter acts like a plug-n-play 3rd party wrapper for communicating with their endpoints (in our case - CompanyFooAdapter
)
- The adapter builds the user data into an XML through a service called
BuildUserXmlService
- The XML is then sent to the 3rd party endpoint
The service builds the user data based on the schema received from the 3rd party
- The 3rd party provides an XML request/response body sample
- We create a 3rd party schema wrapper (in our case -
CompanyFooWrapper
) that loads the XML request/response body sample file into callable methods
To understand more what's happening under the hood, simply run $ rspec --format documentation
or dive into the codes