The SIRI command-line client application is a simple command-line tool for querying SIRI data providers.
You'll need a Java 1.6 runtime installed to run the client. To run the client:
java -jar onebusaway-siri-client-cli.jar [-args] request [request ...]
By default, the SIRI client will construct a single <ServiceRequest/> based on the request spec. The client will send the service request and then wait for a response from the SIRI endpoint. However, other types of requests can be constructed, based on command line arguments:
Each request command line argument indicates a SIRI service or subscription request, defining the properties of the request and the SIRI endpoint. The request has the following syntax:
Key=Value,Key=Value,...
At minimum, you need to specify a Url that indicates the SIRI resource to connect to, and a ModuleType that indicates the SIRI module type to request. Additional keys specific to the module type can be used to further filter the request. For example:
Url=http://host:port/path,ModuleType=VEHICLE_MONITORING,VehicleRef=1234
For more details, see the full command-line request spec documentation.
By default, data received from a remote SIRI data-source will be output to the console. However, with the -output argument, it is possible to write output to disk as well. You can specify a single file, such as:
-output /tmp/siri-output
And all output will go to the file, appending new XML messages as they are received. We also support simple variable substitution of the file name, using the same syntax as java.util.Formatter. We pass a java.util.Date object as the first argument to the formatter, which means you can do complex time-based naming of the output files. For example, the following:
-output /tmp/siri-%1$tFT%1$tT.%1$tL.xml
will write each received XML message to a separate file with a filename that looks like:
/tmp/siri-2011-08-07T13:45:23.023.xml
You can even specify the format as part of the directory name:
-output /tmp/%1$tF/%1$tT.%1$tL.xml
and the application will automatically create the output directory automatically:
/tmp/2011-08-07/13:45:23.023.xml
Say there's a SIRI data source at http://localhost:9090/ that's producing Vehicle Monitoring data. You can subscribe to VM events with the following command:
java -jar onebusaway-siri-client-cli.jar -subscribe Url=http://localhost:9090/,ModuleType=VEHICLE_MONITORING
You should start getting SIRI updates printed to the console:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Siri> <ServiceDelivery xmlns="http://www.siri.org.uk/siri"> <ResponseTimestamp>2011-01-19T17:14:10.049-08:00</ResponseTimestamp> <ProducerRef>5f03db83-f8c0-4060-803a-001ae8dd010d</ProducerRef> <Address>http://localhost:9090</Address> <VehicleMonitoringDelivery> <ResponseTimestamp>2011-01-19T17:14:10.049-08:00</ResponseTimestamp> <RequestMessageRef>dadd8f84-9676-40c7-9de4-1535bf0a9913</RequestMessageRef> <SubscriberRef>bdferris</SubscriberRef> <SubscriptionRef>a528b158-b578-434d-8b56-799fc74c4adb</SubscriptionRef> <VehicleActivity> <MonitoredVehicleJourney> <Delay>P0Y0M0DT0H0M0.490S</Delay> <BlockRef>480060</BlockRef> <CourseOfJourneyRef>15461584</CourseOfJourneyRef> <VehicleRef>2305</VehicleRef> </MonitoredVehicleJourney> </VehicleActivity> </VehicleMonitoringDelivery> </ServiceDelivery> </Siri>