Examples

View the position of vehicles on the map

List of vehicles with details

  • Car #359164
    • Registration number: 2BA7644
    • Mileage: 41883 km
    • Position: 48.816124, 16.648772
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #155117
    • Registration number: 2M5 0018Ppp
    • Mileage: 39885 km
    • Position: 49.570007, 17.251368
    • Current speed: 0 km/h
    • Direction: 210
    • Started: No
  • Car #17639
    • Registration number: 2M50009
    • Mileage: 1763.93 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 510
    • Started: No
  • Car #118344
    • Registration number: 3A41995
    • Mileage: 1220 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #200854
    • Registration number: 3AB 4466
    • Mileage: 213106.19 km
    • Position: 49.468019, 17.100134
    • Current speed: 0 km/h
    • Direction: 138
    • Started: No
  • Car #215557
    • Registration number: 3M5 1227
    • Mileage: 127.7 km
    • Position: 49.601743, 17.241797
    • Current speed: 0 km/h
    • Direction: 348
    • Started: No
  • Car #176146
    • Registration number: 6AX 1980
    • Mileage: 123750 km
    • Position: 49.467976, 17.099855
    • Current speed: 0 km/h
    • Direction: 118
    • Started: No
  • Car #321874
    • Registration number: 6M1 2843 - OBU
    • Mileage: 92943.21 km
    • Position: 49.602226, 17.242291
    • Current speed: 0 km/h
    • Direction: 198
    • Started: No
  • Car #219225
    • Registration number: 6MX 1555
    • Mileage: 81554 km
    • Position: 49.954615, 15.812137
    • Current speed: 0 km/h
    • Direction: 196
    • Started: No
  • Car #296795
    • Registration number: 7AR 6071 - dongle
    • Mileage: 111199 km
    • Position: 49.60214, 17.242334
    • Current speed: 0 km/h
    • Direction: 316
    • Started: No
  • Car #288196
    • Registration number: 7AT 3382
    • Mileage: 32480.62 km
    • Position: 49.602355, 17.242506
    • Current speed: 0 km/h
    • Direction: 54
    • Started: No
  • Car #174177
    • Registration number: 9AS 1854
    • Mileage: 174038.65 km
    • Position: 49.962372, 7.768342
    • Current speed: 0 km/h
    • Direction: 338
    • Started: No
  • Car #200860
    • Registration number: 9B32095
    • Mileage: 15030.89 km
    • Position: 49.599844, 17.218258
    • Current speed: 0 km/h
    • Direction: 172
    • Started: No
  • Car #39557
    • Registration number: Dynavix
    • Mileage: 0 km
    • Position: 49.601636, 17.241969
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #220468
    • Registration number: EL052AF
    • Mileage: 55019 km
    • Position: 49.514754, 17.057712
    • Current speed: 0 km/h
    • Direction: 58
    • Started: No
  • Car #265492
    • Registration number: EL423AR
    • Mileage: 332.86 km
    • Position: 49.560716, 17.732856
    • Current speed: 0 km/h
    • Direction: 124
    • Started: No
  • Car #459080
    • Registration number: EL429BX
    • Mileage: km
    • Position: invalid
    • Current speed: km/h
    • Direction:
    • Started: No
  • Car #416161
    • Registration number: GH4000
    • Mileage: km
    • Position: invalid
    • Current speed: km/h
    • Direction:
    • Started: No
  • Car #462940
    • Registration number: Manik5
    • Mileage: 4660.08 km
    • Position: 49.4679666, 17.0997166
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #310799
    • Registration number: NM325DR
    • Mileage: 138869.45 km
    • Position: 48.655277, 17.881064
    • Current speed: 0 km/h
    • Direction: 144
    • Started: No
  • Car #287776
    • Registration number: OBU jednotka Karoq
    • Mileage: 38999 km
    • Position: 50.050788, 14.436615
    • Current speed: 0 km/h
    • Direction: 274
    • Started: No
  • Car #249597
    • Registration number: Rafa202025Rafa202026Rafa202027Rafa202028
    • Mileage: 0 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #394945
    • Registration number: Test FW 202310
    • Mileage: 106001.04 km
    • Position: 49.974871, 14.078057
    • Current speed: 0 km/h
    • Direction: 354
    • Started: No
  • Car #453443
    • Registration number: Test offline
    • Mileage: km
    • Position: invalid
    • Current speed: km/h
    • Direction:
    • Started: No
  • Car #35518
    • Registration number: tester
    • Mileage: 0 km
    • Position: 49.891325, 14.710758
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #191172
    • Registration number: testovací jednotka OBU
    • Mileage: 32460 km
    • Position: 50.050305, 14.439962
    • Current speed: 0 km/h
    • Direction: 230
    • Started: No
  • Car #348413
    • Registration number: tomtest
    • Mileage: 1600 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #348494
    • Registration number: tomtest2
    • Mileage: 0 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #430294
    • Registration number: tomtest3
    • Mileage: km
    • Position: invalid
    • Current speed: km/h
    • Direction:
    • Started: No
  • Car #316289
    • Registration number: TstRafa007
    • Mileage: 0 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #52863
    • Registration number: Vetronics 711
    • Mileage: 142.71 km
    • Position: 49.601883, 17.241948
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No
  • Car #83393
    • Registration number: WD Fleet offline
    • Mileage: 137000 km
    • Position: invalid
    • Current speed: 0 km/h
    • Direction: 0
    • Started: No

Used functions

Used technologies and tools

Source code

<?php
// login data
$kodf = '****';
$username = '****';
$pass = '****';

$client = new \SoapClient('https://api.webdispecink.cz/code/WebDispecinkServiceNet.php?wsdl');

// array for list of cars
$cars = array();

// the _getCarsList () function returns also car registration number
$car_list = $client->_getCarsList($kodf, $username, $pass);

if (isset($car_list->item) &&
    is_array($car_list->item))
{
    foreach ($car_list->item as $car)
    {
        if ($car->disabled == 0)
        {
            $cars[$car->carid] = array(
                'identifier' => $car->identifikator      // car registration number
            );
        }
    }
}

// last parameter empty - position and other details of all available cars under the specified user
$car_positions = $client->_getCarsIDPosition2($kodf, $username, $pass, '');

if (isset($car_positions->item) &&
    is_array($car_positions->item))
{
    foreach ($car_positions->item as $position)
    {
        if (isset($cars[$position->cd]))
        {
            $cars[$position->cd] += array(                
                'latitude'  => (float)$position->Zs,        // latitude
                'longitude' => (float)$position->Zd,        // longitude
                'speed'  => (int)$position->sd,             // speed
                'running' => (bool)$position->EE,           // key voltage indicator (> 0 = started)
                'tachometer' => (float)$position->Km,       // odometer value
                'direction' => (int)$position->ca,          // driving direction
            );
        }
    }    
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>List of vehicles with details - API Webdispatching</title>        
    </head>
    <body>
        <ul>
<?php
foreach ($cars as $car_id => $car)
{
?>
            <li>
                <strong>Car #<?php echo htmlspecialchars($car_id); ?></strong>
                <ul>
                    <li>Registration number: <?php echo $car['identifier']; ?></li>
                    <li>Mileage: <?php echo $car['tachometer']; ?> km</li>
                    <li>Position: <?php echo ($car['latitude'] == 0 && $car['longitude'] == 0) ? 'invalid' : ($car['latitude'] . ', ' . $car['longitude']); ?></li>
                    <li>Current speed: <?php echo $car['speed']; ?> km/h</li>
                    <li>Direction: <?php echo $car['direction']; ?></li>
                    <li>Started: <?php echo $car['running'] ? "Yes" : "No"; ?></li>
                </ul>
            </li>
<?php
}
?>
        </ul>
    </body>
</html>

Used technologies and tools

Source code

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.soap.*;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class ExampleList
{
    // login data
    private static final String KODF = "****";
    private static final String USERNAME = "****";
    private static final String PASS = "****";
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        Map<Integer, CarInfo> cars = new HashMap<>();
        
        try
        {
            // create a connection for SOAP
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();

            // calling parameters of function_getCarsList ()
            Map<String, String>parametersCarList = new HashMap<>();
            parametersCarList.put("kodf", KODF);
            parametersCarList.put("username", USERNAME);
            parametersCarList.put("pass", PASS);
            
            // SOAP server URL
            String url = "https://api.webdispecink.cz/code/WebDispecinkServiceNet.php?wsdl";
            
            // create a request with parameter for calling the function _getCarsList ()
            SOAPMessage soapRequestCarList = createSOAPRequest("_getCarsList", parametersCarList);
            // calling the function_getCarsList () to get the car registration number
            SOAPMessage soapResponseCarList = soapConnection.call(soapRequestCarList, url);
            
            /*
            Example of server response:

            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn://api.webdispecink.cz/webdisser_02">
                <SOAP-ENV:Body>
                    <ns1:_getCarsListResponse>
                        <return>
                            <item>
                                <cargroupid>0</cargroupid>
                                <carid>1</carid>
                                <identifikator>1M5 76 86</identifikator>
                                ...
                            </item>
                            ...
                        </return>
                    </ns1:_getCarsListResponse>
                </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>                    
            */
            
            // get response body - tag content <SOAP-ENV:Body>
            SOAPBody responseCarList = soapResponseCarList.getSOAPBody();
            // element <ns1:_getCarsListResponse>
            Node getAllCarsPositionResponse = responseCarList.getFirstChild();
            // element <return>
            Node returnContent = getAllCarsPositionResponse.getFirstChild();

            // list of elements <item>
            NodeList items = returnContent.getChildNodes();
            
            int i, j;
            // go through the returned car records
            for (i = 0; i < items.getLength(); i++)
            {
                Node item = items.item(i);
                NodeList data = item.getChildNodes();

                // create a new object of car to store the acquired data
                CarInfo car = new CarInfo();
                
                // browse all items of one record
                for (int k = 0; k < data.getLength(); k++)
                {
                    // text item content
                    String content = data.item(k).getTextContent();
                    
                    switch (data.item(k).getLocalName())
                    {     
                        // unique vehicle identifier
                        case "carid":
                            car.id = Integer.parseInt(content);
                            break;
                            
                        // car registration number
                        case "identifikator":
                            car.identifier = content;
                            break;
                        
                        // is the vehicle being tracked?
                        case "disabled":
                            car.disabled = content.compareTo("1") == 0;
                            break;
                    }
                }
                
                // saves the car for later editing
                cars.put(car.id, car);
            }
            
            // calling parameters of function _getCarsIDPosition2()
            Map<String, String>parametersCarPosition = new HashMap<>();
            parametersCarPosition.put("kodf", KODF);
            parametersCarPosition.put("username", USERNAME);
            parametersCarPosition.put("pass", PASS);
            parametersCarPosition.put("carid_list", "");

            // create a request with parameter for calling the function _getCarsIDPosition2()
            SOAPMessage soapRequestCarPosition = createSOAPRequest("_getCarsIDPosition2", parametersCarPosition);
            // calling the function _getCarsIDPosition2() function to get more data about the car
            SOAPMessage soapResponseCarPosition = soapConnection.call(soapRequestCarPosition, url);
            
            /*
            Example of server response:

            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn://api.webdispecink.cz/webdisser_02">
                <SOAP-ENV:Body>
                    <ns1:_getCarsIDPosition2Response>
                        <return>
                            <item>
                                <cd>17641</cd>
                                <Zs>49.599318</Zs>
                                <Zd>17.247634</Zd>
                                ...                                        
                            </item>
                            ...
                        </return>
                    </ns1:_getCarsListResponse>
                </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>                    
            */
            
            // get response body - tag content <SOAP-ENV:Body>
            SOAPBody responseCarPosition = soapResponseCarPosition.getSOAPBody();            
            // element <ns1:_getCarsIDPosition2>
            Node getCarsIDPosition2Response = responseCarPosition.getFirstChild();
            // element <return>
            returnContent = getCarsIDPosition2Response.getFirstChild();
            
            // browse elements <item>
            items = returnContent.getChildNodes();
            for (i = 0; i < items.getLength(); i++)
            {
                Node item = items.item(i);                
                NodeList data = item.getChildNodes();
                
                CarInfo car = null;                

                // find a vehicle according a unique identifier
                for (j = 0; j < data.getLength(); j++)
                {
                    if (data.item(j).getLocalName().compareTo("cd") == 0)
                    {
                        int id = Integer.parseInt(data.item(j).getTextContent());
                        car = cars.get(id);
                    }
                }
                
                // if vehicle wasn't found by id, continue by next
                if (car == null)
                {
                    continue;
                }                
                
                // browse all items of one record
                for (j = 0; j < data.getLength(); j++)
                {
                    // text item content
                    String content = data.item(j).getTextContent();
                    
                    // skip empty content
                    if (content.isEmpty())
                    {
                        continue;
                    }
                    
                    switch (data.item(j).getLocalName())
                    {
                        // latitude
                        case "Zs":
                            car.latitude = Float.parseFloat(content);
                            break;
                        
                        // longitude
                        case "Zd":
                            car.longitude = Float.parseFloat(content);
                            break;
                        
                        // speed
                        case "sd":
                            car.longitude = Integer.parseInt(content);
                            break;
                        
                        // key voltage indicator (> 0 = started)
                        case "EE":
                            car.running = Boolean.parseBoolean(content);
                            break;
                        
                        // odometer value
                        case "Km":
                            car.tachometer = Float.parseFloat(content);
                            break;
                        
                        // driving direction
                        case "ca":
                            car.direction = Integer.parseInt(content);
                            break;
                    }
                }
            }
            
            // closing the connection
            soapConnection.close();
            
            // list information about cars on the output
            for (Entry<Integer, CarInfo> entry : cars.entrySet())
            {
                CarInfo car = entry.getValue();
                
                // only watched cars
                if (car.disabled == false)
                {
                    System.out.println(car);
                }
            }
        }
        catch (Exception e)
        {
            System.err.println("Error occurred while handling SOAP Request.");
            e.printStackTrace();
        }
    }
    
    private static SOAPMessage createSOAPRequest(String functionName, Map<String, String> parameters) throws Exception
    {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();

        // SOAP Body
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyElem = soapBody.addChildElement(functionName);
        
        // adding parameters
        for (Entry<String, String> entry : parameters.entrySet())
        {
            String key = entry.getKey();
            String value = entry.getValue();
            SOAPElement paramKodf = soapBodyElem.addChildElement(key);
            paramKodf.addTextNode(value);
        }

        soapMessage.saveChanges();

        return soapMessage;
    }
}

public class CarInfo extends Object 
{
    public int id;                      // unique vehicle identifier
    public String identifier;           // car registration number
    public float latitude;              // latitude
    public float longitude;             // longitude
    public int speed;                   // speed
    public boolean running;             // is the vehicle started?
    public float tachometer;            // odometer value
    public int direction;               // driving direction
    public boolean disabled;            // is the vehicle being tracked?
    
    @Override
    public String toString()
    {
        String pattern = 
                "Car #%d%n" +
                "Car registration number: %s%n" +
                "Speedometer: %f km\n" +
                "Geographical location: %f, %f%n" +
                "Current speed: %d km/h%n" +
                "Direction: %d%n" +
                "Started: %s%n";

        String output = String.format(pattern, id, identifier, tachometer, latitude, longitude, speed, direction, running ? "Yes" : "No");

        return output;
    }
}

Used technologies and tools

Source code

using HISoftware.Webdispecink.Api;
using HISoftware.Webdispecink.Api.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            WebdispecinkClientProxy proxy = new WebdispecinkClientProxy
            {
                Company = "xxxx",        // <---- Write your company code
                Username = "xxxxx",      // <---- Write your username
                Password = "xxxxx"       // <---- Write your password
            };

            try
            {
                // Calling GetCarsList API
                Task<IEnumerable<WDS_CarItem>> taskGetCarList = proxy.GetCarsListAsync();
                WDS_CarItem[] listCars = taskGetCarList.Result.ToArray();

                Console.WriteLine($"All cars from \"{proxy.Company}\" company:");
                Console.WriteLine("-------------------------------------");

                foreach (WDS_CarItem carItem in listCars)
                {
                    Console.WriteLine($"License plate: {carItem.identifikator}, Car Id: {carItem.carid}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception {ex.GetType().FullName} has been thrown!\nMessage: \"{ex.InnerException.Message}\"");
            }

            Console.ReadLine();
        }
    }
}