Welcome to the public repo for Elgin Traffic Disruptions Data API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
samples
xsd
Elgin Traffic Disruptions Data API - Data Elements v20170207 (cust).xlsx
README.md
elgin-api-single.wsdl
elgin-api.wsdl
wsdl-contract.zip

README.md

Elgin Traffic Disruptions Data API

Welcome to the public repo for Elgin Traffic Disruptions Data API. Here you can find the specification of the data in form of XSD and WSDL schemas.

The following files and directories are included:

Elgin Traffic Disruptions Data API - Data Elements v20x (cust).xlsx

  • Excel file containing a definition of each field

elgin-api.wsdl

  • SOAP contract and definition

elgin-api-single.wsdl

  • SOAP contract and definition for use in Microsoft Visual Studio

xsd - included API super types gml - included by elginTypes.xsd samples

  • contain data samples in both XML and Json
  • Illustrates WGS84 and British National Grid coordinate systems

WSDL

SOAP implementations

Java

To create Java POJOs from the WSDL and included XSD files run the following (choose any package name):

wsimport -keep -verbose .\elgin-api.wsdl -p com.elgin.elginws.ties

.NET

To create C# POCOs from the WSDL and included XSD files run the following statement. You will first need to download the elgin-api.wsdl and XSD files (see xsd folder).

svcutil.exe .\elgin-api.wsdl .\xsd\elginItems.xsd .\xsd\elginTypes.xsd /language:C# /dataContractOnly /importxmltypes /out:ElginApi.ContractOnly.cs

This will create a file including the web service contract and configuration file with the default endpoint (change this).

The above code is a bit nasty to run. This is due to the WSDL's use of <imports> to include data types in xsd files - this is perfectly normal.

An easier option than the above is using the elgin-api-single.wsdl file that contains all the types and elements from the elgin-api.wsdl file and its includes. However, this single file is an interpretation of the original files and has many of the types and elements copied or abbreviated from the included XSD schemas. I would use the elgin-api-single.wsdl if you are not sure what you are doing in Visual Studio - make sure you change the web service endpoint in the App.config file to bind to a real web service on the Elgin side. You can use this link in Visual Studio.

The .NET configuration file, App.Config, after running the above process will look something like this.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="ElginSOAP" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8080/soap/api/" binding="basicHttpBinding"
                bindingConfiguration="ElginSOAP" contract="ServiceReference.Elgin"
                name="ElginSOAP" />
        </client>
    </system.serviceModel>
</configuration>

This is some code how you can use the client:

using ConsoleApplication1.ServiceReference;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var client = new ElginClient("ElginSOAP", "http://api.roadworks.org/XXXXXXX/"))
            {
                var param = new DataParameterType
                {
                    DataGrouping = DataCType.Items,
                    EntitySourceID = "3450"
                };
                var output = client.GetData("username", "xxxxxxxxxxxxx", param);
            }
        }
    }
}

HTTP POST

The following demonstrates an example POST to the web service. Note that the XXXX denote a specific customer endpoint.

POST http://api.roadworks.org/XXXXXXXX/ HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.elgin.org.uk/elgin/api/GetData"
Host: api.roadworks.org
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <GetDataRequest Account="username" Key="xxxxxxxxxxxxx" xmlns="http://www.elgin.org.uk/schemas/api">
            <DataParameter DataGrouping="Items">
                <ItemType>Road closure</ItemType>
            </DataParamter>
        </GetDataRequest>
    </s:Body>
</s:Envelope>

Good Luck!