2017 © Pedro Peláez
 

library zend-soap-service-provider

A soap service provider, based on ZendSoap from ZendFramwork project.

image

ibsciss/zend-soap-service-provider

A soap service provider, based on ZendSoap from ZendFramwork project.

  • Wednesday, June 4, 2014
  • by lilobase
  • Repository
  • 2 Watchers
  • 5 Stars
  • 2,689 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 8 Versions
  • 4 % Grown

The README.md

zend-soap-service-provider

A soap service provider for Silex, based on the ZendSoap component from ZendFramework project., (*1)

Build Status Coverage Status Latest Stable Version Latest Unstable Version License, (*2)

For more informations about Zend Soap, check the Zend Framework documentation : * Zend Soap Server * Zend Soap Client, (*3)

Why a Zend Soap silex service provider ?

  • For testing
  • For a better integration
  • For simplicity

Install

  1. Add "ibsciss/zend-soap-service-provider": "dev-master" in the require section of your composer.json and run the composer install command.
  2. Register service : $app->register(new ZendSoapServiceProvider()); and don't forget the use \Ibsciss\Silex\Provider\ZendSoapServiceProvider statement.

Usages

Basic use

When the service provider is registered, you have access to the two basic services : * soap.server, instance of Zend\Soap\Server* **soap.client**, instance of Zend\Soap\Client, (*4)

$app = new Application();
$app->register(new ZendSoapServiceProvider());

//client method call
$app['soap.client']->methodCall();

//server handling
$app['soap.server']->handle();

Multiple instances

If you need more connection, you can define several instances using soap.instances parameters., (*5)

//during registration
$app->register(new ZendSoapServiceProvider(), array(
    'soap.instances' => array(
        'connection_one',
        'connection_two'
    )
));

// --- OR ---
$app->register(new ZendSoapServiceProvider());
$app['soap.instances'] = array(
    'connection_one',
    'connection_two'
);

You have access to your instances with the two services : * soap.clients * soap.servers, (*6)

The first defined service is the default one and became accessible from soap.client and soap.server services., (*7)

$app['soap.clients']['connection_one']; //same as $app['soap.client'];
$app['soap.servers']['connection_two'];

WSDL management

You can provide a (optional) WSDL for the global service with the soap.wsdl parameter., (*8)

//during registration
$app->register(new ZendSoapServiceProvider(), array(
    'soap.wsdl' => '<wsdl></wsdl>';
));
// --- OR ---
$app['soap.wsdl'] = '<wsdl></wsdl>';

$app['soap.server']->getWsdl(); //return <wsdl></wsdl>

For multiple instances, its possible to define wsdl for a specific instance :, (*9)

//during registration
$app->register(new ZendSoapServiceProvider(), array(
    'soap.wsdl' => '<wsdl></wsdl>',
    'soap.instances' => array(
        'connection_one',
        'connection_two' => array('wsdl' => '<wsdl>anotherOne</wsdl>')
    );
));

// --- OR ---
$app['soap.wsdl'] = '<wsdl></wsdl>';
$app['soap.instances'] = array(
    'connection_one'
    'connection_two' => array('wsdl' => '<wsdl>anotherOne</wsdl>')
);

Note : if you provide one wsdl per instance you don't have to specify a global one, (*10)

//if you provide one wsdl per instance you don't have to specify a global one
$app->register(new ZendSoapServiceProvider(), array(
    'soap.instances' => array(
        'connection_one' => array('wsdl' => '<wsdl></wsdl>'),
        'connection_two' => array('wsdl' => '<wsdl>anotherOne</wsdl>')
    );
));

$app['soap.servers']['connection_one']->getWsdl() //return <wsdl></wsdl>
$app['soap.servers']['connection_two']->getWsdl() //return <wsdl>anotherOne</wsdl>

About \Zend\Soap implementation

The package use now the official \Zend\Soap package, (*11)

In \Zend\Soap\Server

Debug mode

When an exception is raised in your code the \Zend\Soap\Server catch it and check if this is an authorized exception. If not, and for security reason, it send an "Unknow error" message. And if in production its a sane behavior, its really annoying during development & tests process., (*12)

So the serviceProvider extends the Server class to add a debugMode method which is automatically activated when the silex debug options is true (manual enable/disable debug mode is provide with the setDebugMode($boolean) server method). Example :, (*13)

//enable:
$app['soap.server']->setDebugMode(true);

//disable:
$app['soap.server']->setDebugMode(false);
````

**In debug mode, the Server send all exceptions to the soap client.**

#### Exception management

As described below, when an exception is catch by the `Zend\Soap\Server`, the error message became "Unknown error". So even if you write the exception in logs, you have no ideas of the failure root cause, to avoid this trouble a `getException` method is available in the provider's server class.
Example:

```php
$app['soap.server']->fault(new \Exception('test'));

$app['soap.server']->getException(); //return the Exception instance given as attribute to the fault method.

Internal '\SoapServer' instance

The Zend\Soap\Server use internally a \SoapServer instance to handle request. In certain case, you need an access to this instance (for example to send a SoapFault when the setReturnResponse is set at true). That's why, the provider add a getSoap() method which provide the current internal \SoapServer instance. Example:, (*14)

$app['soap.server']->getSoap()->fault(new \SoapFault('an error occured'));

Advanced topic

Change Soap class

If you want to use your own personal soap class, or for test purpose. You can override the soap, server or client, class with the soap.client.class and soap.server.class., (*15)

Warning: If you are in dotNet mode, you have to use soap.client.dotNet.class (or client.dotNet.class for an instance override)., (*16)

//global level
$app->register(new ZendSoapServiceProvider());

$app['soap.server.class'] = '\stdClass';
$app['soap.client.class'] = '\stdClass';

$app['soap.client']; //instanceOf stdClass;
$app['soap.server']; //instanceOf stdClass;

//----------------
//you can also override at the instance scope
$app = new Application();
$app->register(new ZendSoapServiceProvider(), array(
    'soap.instances' => array(
        'connection_one' => array('server.class' => '\stdClass'),
        'connection_two' => array('client.class' => '\stdClass')
    )
));

$app['soap.clients']['connection_one']; //instanceOf Zend\Soap\Client
$app['soap.servers']['connection_one']; //instanceOf stdClass

$app['soap.clients']['connection_two']; //instanceOf stdClass
$app['soap.servers']['connection_two']; //instanceOf Zend\Soap\Server

Change Soap version

You are able to specify the soap version using the soap.version attribute. The allowed values are :, (*17)

  • SOAP_1_1
  • SOAP_1_2 (default value)
    $app->register(new ZendSoapServiceProvider(), array(
        'soap.version' => SOAP_1_1
    ));

    // ----- OR -----

    $app['soap.version'] = SOAP_1_1;

    //results :
    $app['soap.client']->getSoapVersion(); // SOAP_1_1;
    $app['soap.server']->getSoapVersion(); // SOAP_1_1;

    // -----------------------
    //like others options, you can define it at the instance level :

    $app->register(new ZendSoapServiceProvider(), array(
        'soap.instances' => array(
            'connection_one' => array('version' => SOAP_1_1),
            'connection_two' => array('dotNet' => true),
            'connection_three'
        )
    ));

    $app['soap.clients']['connection_one']->getSoapVersion(); // SOAP_1_1
    $app['soap.servers']['connection_one']->getSoapVersion(); // SOAP_1_1

    //dotNet use 1.1 by default;
    $app['soap.clients']['connection_two']->getSoapVersion(); // SOAP_1_1
    $app['soap.servers']['connection_two']->getSoapVersion(); // SOAP_1_2

    //default config
    $app['soap.clients']['connection_three']->getSoapVersion(); // SOAP_1_2
    $app['soap.servers']['connection_three']->getSoapVersion(); // SOAP_1_2

DotNet specific mode

The dotNet framework process soap parameters a little different than PHP or Java implementations., (*18)

So, if you have to integrate your soap web services with a dotNet server, set the soap.dotNet option at true., (*19)

$app['soap.dotNet'] = true;
$app['soap.client'] // instanceOf Zend\Soap\Client\DotNet

//you can also define it at the instance scope
$app->register(new ZendSoapServiceProvider(), array(
    'soap.instances' => array(
        'connection_one' => array('dotNet' => true),
        'connection_two'
    )
));

$app['soap.clients']['connection_one']; //instanceOf Zend\Soap\Client\DotNet
$app['soap.clients']['connection_two']; //instanceOf Zend\Soap\Client

If you want to override the dotNet class, use the soap.client.dotNet.class attribute instead of soap.client.class., (*20)

Summary

Services

  • soap.client : default soap client instance, alias of the first defined instances
  • soap.server : default soap server instance, alias of the first defined instances
  • soap.clients : soap clients instances container
  • soap.servers : soap servers instances container

parameters

  • soap.wsdl : global wsdl
  • soap.client.class : override client factory class
  • soap.server.class : override server factory class
  • soap.dotNet : enable dotNet mode, use of Soap\Client\DotNet class
  • soap.client.dotNet.class : override client factory class in dotNet mode
  • soap.version : define SOAP version, accept constant SOAP_1_1 or SOAP_1_2 as value (default is SOAP_1_2 unless in dotNet mode)

All parameters can be define at the instance level :, (*21)

$app['soap.instances'] = array(
    'connection_two' => array(
        'wsdl' => '<wsdl>anotherOne</wsdl>',
        'client.class' => '\stdClass',
        'server.class' => '\stdClass',
        'dotNet' => true,
        'client.dotNet.class' => '\stdClass',
        'version' => SOAP_1_1
    )
);

The Versions

04/06 2014

dev-master

9999999-dev

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

04/06 2014

v2.3.2

2.3.2.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

13/02 2014

v2.3.1

2.3.1.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

10/02 2014

v2.3.0

2.3.0.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

09/02 2014

v2.2.0

2.2.0.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

06/02 2014

v2.1.1

2.1.1.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

06/02 2014

v2.1.0

2.1.0.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap

05/02 2014

v1.0.1

1.0.1.0

A soap service provider, based on ZendSoap from ZendFramwork project.

  Sources   Download

MIT

The Requires

 

by Arnaud LEMAIRE

framework silex zend soap service provider service-provider zend-soap zendsoap