Skip to content

Releases: phpro/soap-client

Version 1.0.5

25 Oct 08:44
edb99c5
Compare
Choose a tag to compare

Version 1.0.4

14 Oct 13:46
v1.0.4
42a39af
Compare
Choose a tag to compare

Version 1.0.3

21 May 04:29
v1.0.3
24e4d52
Compare
Choose a tag to compare

Version 1.0.2

10 May 12:01
ace4d3e
Compare
Choose a tag to compare

Version 1.0.1

27 Feb 16:18
v1.0.1
0342e0a
Compare
Choose a tag to compare

Version 1.0.0

22 Feb 09:59
v1.0.0
50a06a2
Compare
Choose a tag to compare

Total issues resolved: 1

Migrating from 0.X

Change your code generation configuration

The code generation configuration has changed:

  • no wsdl methods anymore
  • no soapOptions methods anymore
  • no wsdl provider methods anymore
  • replaced the items above with engine methods (which is required):
<?php

use Phpro\SoapClient\CodeGenerator\Config\Config;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapEngineFactory;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions;

return Config::create()
    ->setEngine(ExtSoapEngineFactory::fromOptions(
        ExtSoapOptions::defaults($wsdl, $soapOptions)
            ->withWsdlProvider($wsdlProvider)
            ->disableWsdlCache()
    ))
    // ....
;

As you can see, the WSDL and the soapOptions are moved to a new ExtSoapOptions class.
The ExtSoapEngineFactory will create a driver based on those soap options and will configure the ExtSoapClientHandle by default.
By providing this new driver system, it will be possible to generate code without ext-soap in the future.
For now, we only suppy the ext-soap driver.

Currently, we are using the default ExtSoapClientHandle in the engine.
You could however change this ext-soap handler to the HttPlugHandle by using the ExtSoapEngineFactory::fromOptionsWithHandler() method.
We've choosen to add the engine instead of the driver to the configuration for advanced future code generation features.

The code generation will work exactly as before. It will only use the new driver metadata implementation to detect methods and types.

Change your factories

Previously we used a lot of classes to get your client up and running.
We decided to remove both the ClientFactory and ClientBuilder and move the configuration to the generated factory.

Most of the configuration is related to the ext-soap SoapClient and is now moved to a new ExtSoapOptions class.
This new class is validated by a resolver. This way you will get a usefull error when you misconfigure one of the many soap options.
The newly introduced options class contains:

  • A wsdl
  • A wsdl provider mechanism
  • A set of default soap options
  • An easy way to configure / overwrite type maps
  • An easy way to configure classmaps

Based on the options, you can now create an ExtSoapDriver which is responsible for encoding / decoding soap requests.
The Handlers are still in charge of doing the actual HTTP requests.
Therefor, you'll have to configure following items directly on the Handler:

  • wsdl middleware
  • soap middleware

When both the driver and handler are configured, we can create a new engine.
Since there are a lot of possible configurations, an easy to use ExtSoapEngineFactory is added.
This one can be used as a shortcut to easily create the engine.

You can transform your builder like one of the examples below:

<?php

namespace App\Client;

use App\Client\Myclient;
use App\Classmap\Myclassmap;
use GuzzleHttp\Client;
use Phpro\SoapClient\Middleware\BasicAuthMiddleware;
use Phpro\SoapClient\Event\Subscriber\LogSubscriber;
use Phpro\SoapClient\Event\Subscriber\ValidatorSubscriber;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapEngineFactory;
use Phpro\SoapClient\Soap\Driver\ExtSoap\ExtSoapOptions;
use Phpro\SoapClient\Soap\Handler\HttPlugHandle;
use Symfony\Component\EventDispatcher\EventDispatcher;

class MyclientFactory
{
    public static function factoryWithRegularExtSoapClient(string $wsdl): Myclient
    {
        $engine = ExtSoapEngineFactory::fromOptions(
            ExtSoapOptions::defaults($wsdl, $oapOptions)
              ->withWsdlProvider($wsdlProvider)
              ->withClassMap(Myclassmap::getCollection())
              ->withTypeMap($typeConverters) // You could also use getTypeMap and add / overwrite
        );

        $dispatcher = new EventDispatcher();
        $dispatcher->addSubscriber(new LogPlugin($logger));
        $dispatcher->addSubscriber(new ValidatorPlugin($validator));

        return new Myclient($engine, $dispatcher);
    }

    public static function factoryWithHttPlug(string $wsdl): Myclient
    {
        $httpHandle = HttPlugHandle::createForClient(Client::createWithConfig($httplugConfig));
        $httpHandle->addMiddleware(new BasicAuthMiddleware('user', 'password'));

        $engine = ExtSoapEngineFactory::fromOptionsWithHandler(
            ExtSoapOptions::defaults($wsdl, $oapOptions)
              ->withWsdlProvider($wsdlProvider)
              ->withClassMap(Myclassmap::getCollection())
              ->withTypeMap($typeConverters),
            $httpHandle
        );

        $dispatcher = new EventDispatcher();
        $dispatcher->addSubscriber(new LogSubscriber($logger));
        $dispatcher->addSubscriber(new ValidatorSubscriber($validator));

        return new Myclient($engine, $dispatcher);
    }
}

As you can see, you can still apply the exact same configuration as before:

  • A new ExtSoapOptions helper is added that makes it a lot easier to configure the ext-soap client.
    • the soapOptions are validated before the SoapClient is constructed. No more documentation lookups! :)
    • The classmap and typeconverters are now reusable in different drivers
    • You can still specify a wsdlProvider which will only be called once the SoapClient is initialized.
  • You now have to add middlewares directly on the HandleInterface
    • This way you cannot add middlewares to handlers that don't know how to deal with HTTP middleware.
  • The handler and engine are combined into an Engine which is injected into your client class.
  • The plugins now have to be enabled directly on the EventDispatcher.
    • You can create a new event dispatcher or use an existing one.

Remove your custom client -factories, -builders, -constructors

Since we removed both the ClientBuilder and Phpro\SoapClient\ClientFactoryInterface,
you will have to move the logic to the new client factory as described above.
Both the builder and clientFactory are permanently removed and will never come back again.

We also changed the constructor of the Client class. It now accepts an Engine and EventDispatcher.
If you changed the constructor signature, you will have to take a look at this as well.

Change namespace of old plugins

One of the first possible ways of extending the soap-client was by adding plugins. Since these plugins are actually event subscribers, it is a better idea to name them EventSubscribers. This is also less confusing with the http-plug plugins which are actually HTTP middlewares.
If you are manually assigning the LogPlugin or ValidatorPlugin, you might need to change these lines as well. The plugins are moved to following locations:

  • LogPlugin -> Phpro\SoapClient\Event\Subscriber\LogSubscriber
  • ValidatorPlugin -> Phpro\SoapClient\Event\Subscriber\ValidatorSubscriber

Version 0.7.11

18 Jan 09:42
82bb72e
Compare
Choose a tag to compare

Version 0.7.10

04 Jan 12:32
4730102
Compare
Choose a tag to compare

Version 0.7.9

30 Nov 15:04
dbd76b8
Compare
Choose a tag to compare

Total issues resolved: 1

Version 0.7.8

19 Oct 13:32
3245acd
Compare
Choose a tag to compare