Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Dublin Bus RTPI

  • 07-01-2014 11:05pm
    #1
    Closed Accounts Posts: 295 ✭✭


    I'm trying to use the functionality here http://rtpi.dublinbus.biznetservers.com/DublinBusRTPIService.asmx to get information about Dublin buses. There is one function in particular (GetRealTimeStopData) that seems like it should be straight forward but its not. It seems like it just accepts a bus stop number and some sort of Boolean value.

    I'm trying to do this in C# but I'm making zero progress with it.

    Any ideas about how to use this? Its based on SOAP I think but I'd know more about a bar of Palmolive soap than I do about this, I haven't a clue where to begin.

    Any help would be much appreciated.

    Thanks!


Comments

  • Registered Users, Registered Users 2 Posts: 3,078 ✭✭✭onemorechance


    You need to create or use an existing SOAP connector.
    POST /DublinBusRTPIService.asmx HTTP/1.1
    Host: rtpi.dublinbus.biznetservers.com
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://dublinbus.ie/GetRealTimeStopData"
    
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
        <GetRealTimeStopData xmlns="http://dublinbus.ie/">
          <stopId>int</stopId>
          <forceRefresh>boolean</forceRefresh>
        </GetRealTimeStopData>
      </soap:Body>
    </soap:Envelope>
    

    Basically you need to send the above as a POST RQ over HTTP.

    Replace int with the number of the stop in:

    <stopId>int</stopId>

    Replace boolean with either true or false in:

    <forceRefresh>boolean</forceRefresh>
    SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on XML Information Set for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.
    ...

    Wiki

    SOAP UI is a good tool for testing SOAP services.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    If you're using Visual Studio then you can add a Service Reference and point it at the service endpoint. This will generate the service methods so that they can be be used much like a referenced external library.


  • Closed Accounts Posts: 295 ✭✭kryptonmight


    Yeah been trying to work that out using visual studio for a windows phone app. I have the service reference added but I cant seem to figure out how to read what i get back. When i check the e.result which is returned, its just the name of the method or service, no data that I can see.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Yeah been trying to work that out using visual studio for a windows phone app. I have the service reference added but I cant seem to figure out how to read what i get back. When i check the e.result which is returned, its just the name of the method or service, no data that I can see.

    If you post some code we might be able to help. The result returned could be a custom object defined by the contract and generated when you added the service reference.

    You can find this by going to Object Explorer and navigating to the Namespace you specified when adding the service reference.


  • Closed Accounts Posts: 295 ✭✭kryptonmight


    Will post some code later when i get home.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Ok,

    It's working fine for me. I would suggest removing and readding the service reference. I used the name "DublinBusService" when adding it.

    The results are returned in a Datatable so it's easy enough to take what you want.

    Here's the code:
    var client = new DublinBusService.DublinBusRTPIServiceSoapClient();
    var result = client.GetRealTimeStopData(777, true);
                
    //Iterate through the results
    foreach (DataRow row in result.Rows)
    {
                    var routeNumber = row["MonitoredVehicleJourney_LineRef"];
                    var destination = row["MonitoredVehicleJourney_DestinationName"];
                    var arrivalTime = Convert.ToDateTime(row["MonitoredCall_ExpectedArrivalTime"]);
    
                    var displayText = string.Format("{0} to {1} arrives at {2}", routeNumber, destination,
                                                    arrivalTime.ToShortTimeString());
    
    System.Diagnostics.Debug.WriteLine(displayText);
    }
    

    Here's the result:
    145 to Heuston Stn via Donnybrook arrives at 10:11
    46A to Phoenix Pk via Donnybrook arrives at 10:12
    39 to Ongar via B'stown Shopping Centre arrives at 10:18
    145 to Heuston Stn via Donnybrook arrives at 10:23
    145 to Heuston Stn via Donnybrook arrives at 10:23
    46A to Phoenix Pk via Donnybrook arrives at 10:24
    39 to Ongar via B'stown Shopping Centre arrives at 10:28
    46A to Phoenix Pk via Donnybrook arrives at 10:28
    145 to Heuston Stn via Donnybrook arrives at 10:36
    39 to Ongar via B'stown Shopping Centre arrives at 10:38
    46A to Phoenix Pk via Donnybrook arrives at 10:42


  • Closed Accounts Posts: 295 ✭✭kryptonmight


    John_Mc wrote: »
    Ok,

    It's working fine for me. I would suggest removing and readding the service reference. I used the name "DublinBusService" when adding it.

    The results are returned in a Datatable so it's easy enough to take what you want.

    Here's the code:
    var client = new DublinBusService.DublinBusRTPIServiceSoapClient();
    var result = client.GetRealTimeStopData(777, true);
                
    //Iterate through the results
    foreach (DataRow row in result.Rows)
    {
                    var routeNumber = row["MonitoredVehicleJourney_LineRef"];
                    var destination = row["MonitoredVehicleJourney_DestinationName"];
                    var arrivalTime = Convert.ToDateTime(row["MonitoredCall_ExpectedArrivalTime"]);
    
                    var displayText = string.Format("{0} to {1} arrives at {2}", routeNumber, destination,
                                                    arrivalTime.ToShortTimeString());
    
    System.Diagnostics.Debug.WriteLine(displayText);
    }
    

    Here's the result:

    Cheers dude, will check this out later.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Should have said this is the synchronous way of doing things. You'll probably need to do it asynchronously so that your UI doesn't freeze up while executing the call. There are plenty of examples out there showing you how to define a callback method which is fired when the asynchronous method has completed.

    Post your code on here if you continue to have problems.


  • Closed Accounts Posts: 295 ✭✭kryptonmight


    I'm doing this in C# on Windows Phone so the way you write the methods is different. With Windows Phone you seem to be forced into writing a response method.

    Anyway, here's what I've got so far but e.Result seems to be null. I've deleted and re-added the Service Reference;
    private void doSomething()
            {
                int stop = 2064;
                
                DublinBusService.DublinBusRTPIServiceSoapClient client = new DublinBusService.DublinBusRTPIServiceSoapClient();
                client.GetRealTimeStopDataCompleted += client_Completed;
                client.GetRealTimeStopDataAsync(stop, true);
            }
    
            void client_Completed(object sender, dynamic e)
            {
                if (e.Error != null)
                {
                }
                else
                {
                    string Result = e.Result;
                    MessageBox.Show(Result);
                }
            }
    


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    I'm doing this in C# on Windows Phone so the way you write the methods is different. With Windows Phone you seem to be forced into writing a response method.

    Anyway, here's what I've got so far but e.Result seems to be null. I've deleted and re-added the Service Reference;
    private void doSomething()
            {
                int stop = 2064;
                
                DublinBusService.DublinBusRTPIServiceSoapClient client = new DublinBusService.DublinBusRTPIServiceSoapClient();
                client.GetRealTimeStopDataCompleted += client_Completed;
                client.GetRealTimeStopDataAsync(stop, true);
            }
    
            void client_Completed(object sender, dynamic e)
            {
                if (e.Error != null)
                {
                }
                else
                {
                    string Result = e.Result;
                    MessageBox.Show(Result);
                }
            }
    

    You can't use the Dynamic keyword in your callback method. With web services, it's based on a contract between the provider and the consumer - both sides need to know the data & types being sent/received.

    Change your callback method to this:
    void client_Completed(object sender, GetRealTimeStopDataCompletedEventArgs e)
            {
                if (e.Error != null)
                {
                    //TODO: Handle error
                }
                else
                {
                    if (e.Result.Rows.Count > 0)
                    {
                        foreach (DataRow row in e.Result.Rows)
                        {
                            var routeNumber = row["MonitoredVehicleJourney_LineRef"];
                            var destination = row["MonitoredVehicleJourney_DestinationName"];
                            var arrivalTime = Convert.ToDateTime(row["MonitoredCall_ExpectedArrivalTime"]);
    
                            var displayText = string.Format("{0} to {1} arrives at {2}", routeNumber, destination,
                                                            arrivalTime.ToShortTimeString());
    
                            System.Diagnostics.Debug.WriteLine(displayText);
                        }
                    }
                    
                }
            }
    

    You'll get results like this:

    145 to Heuston Stn via Donnybrook arrives at 21:29
    46A to Phoenix Pk via Donnybrook arrives at 21:35
    145 to Heuston Stn via Donnybrook arrives at 21:49
    46A to Phoenix Pk via Donnybrook arrives at 21:55
    145 to Heuston Stn via Donnybrook arrives at 22:08
    46A to Phoenix Pk via Donnybrook arrives at 22:15

    Not sure if you came across this Github repo but it might help you get up and running a bit faster.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 116 ✭✭Rabbitt


    Very basic question here
    How does RTPI work? Is the total journey time broken up from stop to stop
    Eg from stop 1 to stop 1 is 6 mins?
    Or is it moate technical and calculates the bus location and traffic and avg speed?


  • Registered Users, Registered Users 2 Posts: 1,266 ✭✭✭Overflow


    It uses GPS as far as i know. The geo position of each bus stop is known and some sort of routing algorithm estimates the buses arrival to a stop based on its current GPS location and possibly live traffic info.


Advertisement