| 8:37 am on May 4, 2012 (gmt 0)|
| 4:08 pm on May 10, 2012 (gmt 0)|
| 8:40 am on May 16, 2012 (gmt 0)|
Last bump before it's off to join Experts Exchange ;)
| 12:42 pm on May 16, 2012 (gmt 0)|
Cache on what level? You want to cache the $body var contents? You want to cache the response, wsdl cache or what?
| 1:08 pm on May 16, 2012 (gmt 0)|
I want to cache the response, so basically if the same $body is requested within half an hour, the cached response is shown as opposed to making a new SOAP call.
| 6:25 pm on May 16, 2012 (gmt 0)|
In the nusoap library you should have a class called nusoap_wsdlcache. Here is some code
// Setup the requested url
$req = 'http://example.com/request.wsdl';
// Cache for half hour in the cache folder
$soap_cache = new nusoap_wsdlcache('/cache', 1800);
// Check if request is in cache
$soap_wsdl = $soap_cache->get($req);
// If not in cache make a record
$soap_wsdl = new wsdl($req);
// Create the client object
$soap_client = new nusoap_client($soap_wsdl, true);
So if the request is already cached it won't be recreated.
| 9:09 pm on May 17, 2012 (gmt 0)|
I understand that but just don't understand how to change the code below to work with caching.
$s = new nusoap_client('https://api.example.com/API.asmx');
$msg = $s->serializeEnvelope($body);
$s -> send($msg,'https://api.example.com/API.asmx/CheckAvailability');
$response = $s->document;
| 10:32 am on May 18, 2012 (gmt 0)|
The 'https://api.example.com/API.asmx'is effectively what should be in the $req variable above. Otherwise each time you construct the client the code will parse the wsdl.
Now for the specific response to be cached you could use a database or file and store the data. You could use a signature to reference the specific entry based on the request and retrieve it thereafter. For example:
$signature = md5($msg . 'https://api.example.com/API.asmx/CheckAvailability');
which can be used as a db column or filename so you can check if present and if it is retrieve its content without doing the "send"