2017 © Pedro PelĂĄez
 

library webservice-bundle

This bundle allows to synchronize a table with a soap webservice.

image

heristop/webservice-bundle

This bundle allows to synchronize a table with a soap webservice.

  • Thursday, February 6, 2014
  • by heristop
  • Repository
  • 1 Watchers
  • 2 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WebServiceBundle

This bundle allows to synchronize a table with a soap webservice., (*1)

Installation

Download sources from github:, (*2)


[HeriJobQueueBundle] git=https://github.com/heristop/HeriWebServiceBundle.git target=/bundles/Heri/WebServiceBundle/

Or use composer adding the requirement below:, (*3)

``` js { "require": { "heristop/webservice-bundle": "*" } }, (*4)


Register namespace in autoload: ```php $loader->registerNamespaces(array( ... 'Heri' => __DIR__.'/../vendor/bundles', ));

Load in AppKernel:, (*5)

    $bundles[] = new Heri\WebServiceBundle\HeriWebServiceBundle();

Usage

First, add the column toUpdate in your entity definition. This field will be set to false after the synchronization:, (*6)


/** * @ORM\Column(name="to_update", type="boolean") */ protected $toUpdate;

Generate getters and setters:, (*7)

    app/console doctrine:generate:entities %YourBundle%

Create a class in %YourBundle%/Service directory to apply the mapping with the WSDL. The bundle contains an example:, (*8)


namespace Heri\Bundle\WebServiceBundle\Service; use Heri\Bundle\WebServiceBundle\ClientSoap\ClientObject; class Sample extends ClientObject { public function configure() { $this->name = 'sample'; $this->table = 'HeriWebServiceBundle:Sample'; $this->func = 'addSample'; } public function hydrate($record) { $this->params = array( 'id' => $record->getId(), 'label' => $record->getLabel(), ); } }

Configure the webservices connection in config.yml:, (*9)


heri_web_service: namespaces: [ %YourBundleNamespace%\Service ] authentication: # optional login: %login% password: %password% webservices: brand: name: brand url: %soap_url% authentication: true # optional

Then, use this command to call a webservice and retrieve all the records with toUpdate to true:, (*10)

    app:console webservice:load %Service%

To see the list of available functions add list option., (*11)

Configuration

Edit config.yml to add SyncListener:, (*12)


services: sync.listener: class: Heri\Bundle\WebServiceBundle\Listener\SyncListener tags: - { name: doctrine.event_listener, event: prePersist, connection: default } - { name: doctrine.event_listener, event: postPersist, connection: default }

JobQueue

This bundle can be used with HeriJobQueueBundle to manage multiple webservice connections., (*13)

Override configuration and add the depedency to jobqueue service in config.yml:, (*14)


services: sync.listener: class: Heri\Bundle\WebServiceBundle\Listener\SyncListener arguments: [@jobqueue] tags: - { name: doctrine.event_listener, event: prePersist, connection: default } - { name: doctrine.event_listener, event: postPersist, connection: default } jobqueue: class: Heri\Bundle\JobQueueBundle\Service\QueueService arguments: [@logger] tags: - { name: monolog.logger, channel: jobqueue }

Add a method called synchronize() in the object which return the name of queue:, (*15)


/** * Adds synchronization in specified queue * * @return string */ public function synchronize() { return '%queue_name%'; }

When the record will be saved in database, the synchronization to the webservice will be pushed in queue., (*16)

Note

You can override the ClientObject class in order to apply a specific configuration., (*17)

The example below shows the method to connect your application to a Magento plateform:, (*18)


heri_web_service: namespaces: [ %YourBundleNamespace%\Service ] authentication: login: sampleuser password: 123456 webservices: magento: name: api url: http://myshop-local.com/index.php/api/

abstract class ClientMagento extends ClientObject { protected $name = 'api'; protected function callFunction($func, array $params = array()) { $connection = $this->getContainer()->getConnection(); $sessionId = $this->client->login($connection->getLogin(), $connection->getPassword()); return $this->client->call( $sessionId, $func, $params ); } }

The Versions

06/02 2014

dev-master

9999999-dev

This bundle allows to synchronize a table with a soap webservice.

  Sources   Download

MIT

The Requires

 

by Alexandre MogĂšre

doctrine sf2 queue soap webservice propel