BLOG

When the API you're working with changes and you can't get the server to see new operations, it's probably the WSDL caching. Here's how to fix it.

api-error.jpg

How to fix server not detecting API changes (cached wsdl)

15th April 2016

I had an issue this morning working on a client's production server where some live API changes (owned by a third party) weren't being picked up. So a new operation has been added (and the code has been successfully deployed), yet there are issues.

The environment is load balanced with 3 production servers, 1 of these environments could see the new API operation whereas the other 2 could not. The issue was because the WSDL had been cached. There are two ways to deal with this:

1. Delete the cache

The server in question was a CentOS 6 box, so in /tmp/ were a number of cached WSDL files. Delete these.

You will need to do this every time the API changes significantly though, so it might be worth creating a script to do it (or add it to your deployment recipe if it's going to be a common problem).

2. Tell PHP to stop caching the WSDL entirely

When you instantiate the Soap Client, you can pass through a configuration parameter instructing it to avoid caching the WSDL. This is done as such:

    
$client = new SoapClient('http://somewhere.com/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE) );
    

I wouldn't recommend doing this unless you can help it, as fetching the WSDL on each request could really slow down the website. But it's a viable option. You could also specifiy this as an ini set:

    
ini_set("soap.wsdl_cache_enabled", 0);
    

Or you could of course configure that as part of your PHP config. I'd recommend going for approach #1 though, as it's not likely to be a regular-enough issue to cause you sufficient distress to make the user-experience for users that much worse.

Hope this helps.

THINK THERE'S SOMETHING WE CAN TALK ABOUT?

Whether you want to discuss a piece of business, get advice on how to approach something in Concrete5, want my top Project Zomboid tips or just simply want to say hello, then please do. I'm not as anti-social as my status as a developer would suggest.

GET IN TOUCH

CONTACT

Image
LOCATION
Milton Keynes (near London)
Image
PHONE
Disclosed for business only
Image
E-MAIL
steven.york [at] seopher.com
Image
AVAILABILITY
Contact me to find out