Re: [onebusaway-users] Example showing server and client initialization etc

48 views
Skip to first unread message
Message has been deleted

Brian Ferris

unread,
Jan 1, 2013, 3:42:27 AM1/1/13
to onebusaw...@googlegroups.com
Regarding your specific example, if you are sending the ServiceDelivery from within the SiriSubscriptionRequestHandler, it's important to note that the subscription hasn't actually been fully registered at that point.  As such, the ServiceDelivery goes doesn't get sent to the client.  (Maybe worth changing that behavior for SiriSubscriptionRequestHandler?)

Generally speaking, deliveries aren't sent on a per-client basis.  Instead, you just publish general ServiceDeliveries to the Server (via server.publish(serviceDelivery);) and the server figures out which active subscriptions would be interested.

Some good places to look at example code:


Wish I could offer more, but I'm going to be traveling for the next week with limited internet.  Good luck in the meantime!

Brian


On Fri, Dec 28, 2012 at 9:45 PM, Ben Short <b...@benshort.co.uk> wrote:
Hi, 

In the new year I have been tasked with developing a SIRI consumer that will need to create stop monitoring subscriptions and receive stop monitoring and heart beat deliveries.

To get a bit of a head start I wanted to use the onebusaway library to set up a simple server and client example. Here is what I have so far...

Set<Module> modules = new HashSet<>();
        SiriJettyModule.addModuleAndDependencies(modules);
        SiriCoreModule.addModuleAndDependencies(modules);
        Injector injector = Guice.createInjector(modules);
        
        final SiriServer server = injector.getInstance(SiriServer.class);
        // Set our SIRI identity
        server.setIdentity("me");
        // Change the port and url we listen to for incoming client requests
        server.setUrl("http://127.0.0.1:8080/server.xml");
                
        server.addSubscriptionRequestHandler(new SiriSubscriptionRequestHandler() {

            @Override
            public void handleSubscriptionRequest(SubscriptionRequest request) {
                
                                
                ServiceDelivery serviceDelivery = new ServiceDelivery();
                serviceDelivery.setAddress(request.getAddress());
                
                server.publish(serviceDelivery);
                
                
            }
        });

        
        SiriClient client = injector.getInstance(SiriClient.class);
        // Set our SIRI identity
        client.setIdentity("me");
        // Change the port and url we listen to for incoming service deliveries
        client.setUrl("http://127.0.0.1:8081/client.xml");
        // Register a service delivery handler
        client.addServiceDeliveryHandler(new SiriServiceDeliveryHandler() {

            @Override
            public void handleServiceDelivery(SiriChannelInfo sci, ServiceDelivery sd) {
                throw new UnsupportedOperationException("Client Not supported yet.");
            }
            
        });
        
        
        
        // Start the server and client
        LifecycleService lifecycleService = injector.getInstance(LifecycleService.class);
        lifecycleService.start();
        
        
        Siri siri = new Siri();
        
        SubscriptionRequest subscriptionRequest = new SubscriptionRequest();
        
        StopMonitoringSubscriptionStructure stopMonitoringSubscriptionStructure = new StopMonitoringSubscriptionStructure();        
        
        subscriptionRequest.getStopMonitoringSubscriptionRequest().add(stopMonitoringSubscriptionStructure);
        
        siri.setSubscriptionRequest(subscriptionRequest);
        
        SiriClientRequest request = new SiriClientRequest();
        request.setTargetUrl(server.getUrl());
        request.setTargetVersion(ESiriVersion.V1_3);
        request.setPayload(siri);
        request.setSubscribe(false);

        client.handleRequest(request);

The servers SiriSubscriptionRequestHandler gets called the log output shows that the client gets a SubscriptionResponse. But I see no service delivery on the client side.

Could anyone give me some pointers on how to get this example working? I've not used guice before either so I'm not sure if I need to set the servers subscription manger myself or not.

--
You received this message because you are subscribed to the Google Groups "onebusaway-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/onebusaway-users/-/XJoMFLef6dEJ.
To post to this group, send email to onebusaw...@googlegroups.com.
To unsubscribe from this group, send email to onebusaway-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/onebusaway-users?hl=en.

Ben Short

unread,
Jan 1, 2013, 1:07:06 PM1/1/13
to onebusaw...@googlegroups.com
Hi Brian,

Thanks for the info. After a while I found the Siri Intergration Test module [1] which gave me a good example of setting up the client and server. I've not managed to get a notification from the server for a Stop Monitoring subscription as yet but will keep trying.

Am I right in saying that the OneBusAway server and client don't exchange data using SOAP? 

Again many thanks for your time.

Brian Ferris

unread,
Jan 1, 2013, 1:53:18 PM1/1/13
to onebusaw...@googlegroups.com

They don't use SOAP in the strict sense of the term.  They do pass XML messages back and forth in a SOAP- like manner, as defined by the SIRI standard.  I've only ever tested it against one other SIRI implementation but it does seem to work ;-)

To view this discussion on the web visit https://groups.google.com/d/msg/onebusaway-users/-/fwXP1oLkn0cJ.

Ben Short

unread,
Jan 1, 2013, 2:17:36 PM1/1/13
to onebusaw...@googlegroups.com
While looking at the SIRI schemas [1] the producer and consumer WSDL files threw me. I tried sending soap using SoapUI to the server and in the end figured out that it doesn't accept SOAP as defined in the WSDL's.

I'll know tomorrow what the system I have to integrate with is expected. Looking at the documentation they have given me so far it looks like its plain HTTP posts with data as defined by the SIRI standard. Fingers crossed it is and your work will save me a lot of development :) If not then I'll either have to add SOAP support to your code or roll something of my own.

Reply all
Reply to author
Forward
0 new messages