From our previous blog post we have seen how easy it is to setup a seamless integration between the XI 52 and XC 10. In this blog post, we dive into a little more detail of the seamless integration by understanding how datapower encodes and decodes the cache key.
Datapower XI 52 uses the URL as the cache key for the storing and retrieving of the object from XC 10 caching device. When a request is made to the XI52, XI 52 will make a call to the backend and store the successful response in XC 10 device with encoded URL as cache key. For the consecutive requests XI 52 will use the encoded request URL as cache key to retrieve it from the cache. The conversion of the URI into cache key is two-step process,
- The request URL is base64 encoded with input character set as UTF-8
- Then result is then URL encoded.
The result will be a cache key which can be used to retrieve the cached object.
For example,
- Let’s assume the request URL for a service on Datapower XI 52 with seamless integration enabled with XC 10 stored in grid name “physician” is
http://www.hospitial.com:5454/physician/appointments/list?StartDate=08/14/2014&EndDate=08/26/2014
- The base 64 encoded version will be
aHR0cDovL3d3dy5ob3NwaXRpYWwuY29tOjU0NTQvcGh5c2ljaWFuL2FwcG9pbnRtZW50cy9saXN0P1N0YXJ0RGF0ZT0wOC8xNC8yMDE0JkVuZERhdGU9MDgvMjYvMjAxNA== - By URL encoding the above result we will get the cache key aHR0cDovL3d3dy5ob3NwaXRpYWwuY29tOjU0NTQvcGh5c2ljaWFuL2FwcG9pbnRtZW50cy9saXN0P1N0YXJ0RGF0ZT0wOC8xNC8yMDE0JkVuZERhdGU9MDgvMjYvMjAxNA%3D%3D
To retrieve the cached object using the cache key we need to point to correct data grid.
https://CacheCollective/resources/datacaches/{gridname} /{gridname.LUT}/{cachekey}
Calling the above URL with valid credentials will retrieve the cached object.In our example the URL will look like
https://CacheCollective/resources/datacaches/ physician/ physician.LUT/ aHR0cDovL3d3dy5ob3NwaXRpYWwuY29tOjU0NTQvcGh5c2ljaWFuL2FwcG9pbnRtZW50cy9saXN0P1N0YXJ0RGF0ZT0wOC8xNC8yMDE0JkVuZERhdGU9MDgvMjYvMjAxNA%3D%3D
CURL Command for cache object retrieval
curl –user <username>:<password> -k https://{XC10deviceaddress/resources/datacaches/ physician/ physician.LUT/ aHR0cDovL3d3dy5ob3NwaXRpYWwuY29tOjU0NTQvcGh5c2ljaWFuL2FwcG9pbnRtZW50cy9saXN0P1N0YXJ0RGF0ZT0wOC8xNC8yMDE0JkVuZERhdGU9MDgvMjYvMjAxNA%3D%3D
The following are the scenarios decoding the XC 10 key will be helpful
- Retrieve the object stored using seamless integration from different Multi-protocol gateway.
- Building the URL to call through CURL/command line
- Debugging the integration issues
Links
- Base 64 encoding http://www.base64encode.org/
- URL encoder http://meyerweb.com/eric/tools/dencoder/