olegkhuss/verilocationsoapbundle

Symfony2 bundle for verilocation soap client

0.3.0 2016-03-30 10:13 UTC

This package is auto-updated.

Last update: 2024-12-23 02:37:15 UTC


README

Sample usage

Include in composer.json

{
    .....
	"require": {
		"olegkhuss/verilocationsoapbundle": "~0.2@dev"
	}
}

config.yml

gelo_verilocation_soap:
    auto_logon: false
    username: <username>
    password: <password>
    wsdl: 'http://www.verilocation.com/gps/xml/version_001.asmx?wsdl'
# SoapClient options see http://php.net/manual/ru/soapclient.soapclient.php
#    options: ~ 

PHP code

<?php
// ...
public function indexAction(Request $request)
{
    $client = $this->get('gelo_verilocation_soap.client');
    try {
        $client->doLogon(
            $this->container->getParameter('gelo_verilocation_soap.client.username'),
            $this->container->getParameter('gelo_verilocation_soap.client.password')
        );

        // is webservice active?
        print_r($client->isWebserviceActive());
        // get all vehicles
        print_r($client->getVehicles());
        // get all vehicles extended
        print_r($client->getVehiclesExt());
        // get all latest positions
        print_r($client->getLocationsLatest());

    } catch (\Exception $e) {
        // could not login, check username/password
        throw $e;
    }
}

if `auto_logon: true`, avoid manual doLogon call

<?php

public function indexAction(Request $request)
{
    try {
        $client = $this->get('gelo_verilocation_soap.client');
        // is webservice active?
        print_r($client->isWebserviceActive());
        // ...

    } catch (\Exception $e) {
        // could not login, check username/password
        throw $e;
    }
}