homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

nusoap 0.9.5

 9:24 am on May 3, 2012 (gmt 0)

I'm retrieving data from a webservice using nusoap. With a lot of trial and error I've managed to send and receive data. I'm now interested in enabling caching. I've searched google but none of the examples make sense. Would anyone be kind enough to tell me how enable for caching for the following call.

$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;

Thank you in advance.



 8:37 am on May 4, 2012 (gmt 0)

Bump ;)


 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)

Hi Enigma1

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
if(empty($soap_wsdl)) {
$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)

Hi Enigma1

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"

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved