Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CachedWsdlProvider #305

Merged
merged 2 commits into from
Jul 15, 2020
Merged

Add CachedWsdlProvider #305

merged 2 commits into from
Jul 15, 2020

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Jun 24, 2020

Fixes #63

The old HttPlugWsdlProvider does not work exactly the way you would think it works.
This PR is contains an improved CachedWsdlProvider with a separated HttpWsdlLoader
This implementation makes it possible to cache a WSDL temporary or permanent.

Usage:

<?php
use Http\Client\Common\PluginClient;
use Http\Discovery\Psr17FactoryDiscovery;
use Phpro\SoapClient\Wsdl\Loader\HttpWsdlLoader;
use Phpro\SoapClient\Wsdl\Provider\CachedWsdlProvider;
use Symfony\Component\Filesystem\Filesystem;

$loader = new HttpWsdlLoader(
    new PluginClient($httpClient, [
         // You can add WSDL middlewares in here. E.g.: authentication, manipulations, ...
    ]),
    Psr17FactoryDiscovery::findRequestFactory()
);
$provider = new CachedWsdlProvider($loader, new Filesystem(), sys_get_temp_dir());
$wsdl = $provider->provide('https://somehost/service.wsdl');

Another mode is the forcePermanentDownloads mode:

$provider->forcePermanentDownloads()->provide('http:https://somehost/service.wsdl');

This enables you to create a CLI command that caches WSDLs for production environments that don't change often in a cronjob. This means that the WSDL won't be downloaded from the remote server on every request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GuzzleWsdlProvider fills up tmp with cache files and keeps downloading WSDL file
1 participant