Web Service - Version Mismatch No Exception Thrown In Client

Supporting Java SE version 7 and up
RobOrt
Phidgeteer!
Posts: 85
Joined: Wed Jun 17, 2009 11:39 am
Contact:

Web Service - Version Mismatch No Exception Thrown In Client

Postby RobOrt » Sun Sep 25, 2011 7:54 am

Hi,

I've been working on improving the error handling in my AndroidPhidgets code. In particular I've been testing for version mismatch between client and webservice version, my client running version 2.1.7 of the Phidget library and the WebService running 2.1.8.

When running the Webservice in debug mode it correctly reports the version mismatch and rejected connection attempts but in my client code there is no exception thrown or error given.

I should also point out that this occurs when opening a remote Phidget Manager and I notice from the documentation that Manager is not descended from Phidget class but from Java Object. Consequently I cannot attach an Error Listener to my Manager object and nothing is thrown to the catch block surrounding Manager.open() line:

Code: Select all

try{
            m.open(ip, port);
            Message msg = Message.obtain(guiHandler);
            msg.obj = "Connecting to " + ip + ":" + port;
            msg.arg1 = AndroidPhidget.DISPLAYMESSAGE;
            msg.sendToTarget();
         } catch (PhidgetException e) {
            Message msg = Message.obtain(guiHandler);
            msg.obj = e.toString();
            msg.arg1 = AndroidPhidget.DISPLAYMESSAGE;
            msg.sendToTarget();
         }


Does Manager not report/throw exception should Webservice version mismatch occur? (Note this is library version 2.1.7)

User avatar
Patrick
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Web Service - Version Mismatch No Exception Thrown In Cl

Postby Patrick » Mon Sep 26, 2011 12:43 pm

The manager does support error handlers - but for some reason, this functionality isn't brought out to Java. I'll put this on the fix-list.

-Patrick

RobOrt
Phidgeteer!
Posts: 85
Joined: Wed Jun 17, 2009 11:39 am
Contact:

Re: Web Service - Version Mismatch No Exception Thrown In Cl

Postby RobOrt » Tue Sep 27, 2011 7:54 am

Hi Patrick,

I assume that the Dictionary object doesn't include Error handling either as it's not descendent from Phidget object so would be handy to give Dictionary this functionality too.

I've managed to come up with a 'work-around' that will report all thrown errors to my own descendent of the Manager object. Basically, within my own Manager descendent I create a fictitious Phidget device e.g. Interface Kit and attach an ErrorListener to it (which happens to be a method of my own Manager descendent). to open the Interface Kit I chose a serial number at random e.g. 2 but just to be on the safe side, are there any serial numbers that are/will be unavailable in devices on the market?

I don't even have to open an InterfaceKit as it can be any descendent of Phidget but I just wanted to be sure I'm using a device serial number that will not be available.

Thanks

User avatar
Patrick
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Web Service - Version Mismatch No Exception Thrown In Cl

Postby Patrick » Tue Sep 27, 2011 9:39 am

Ok, I will add it to the dictionary also. 2 should be safe. You could also use 0, as there has never been a Phidget with that serial.

-Patrick

RobOrt
Phidgeteer!
Posts: 85
Joined: Wed Jun 17, 2009 11:39 am
Contact:

Re: Web Service - Version Mismatch No Exception Thrown In Cl

Postby RobOrt » Wed Sep 28, 2011 3:36 pm

Many thanks Patrick.


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest