SBC Programming (JAVA) - Consume A Simple WebService

Supporting Java SE version 7 and up
morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Tue Nov 19, 2013 2:14 am

I have code that will consume a C# created web service. It runs in java on my computer, but it will not run on the Phidget. Am I running the wrong version of Java? Is there a better library to use?

I need some help as to where to the supporting .jars or class files go? Do I build a userspace application and upload my .jar (NETBEANS) and the javax.xml.ws files? what do I need...?

Any help is appreciated!!

Code: Select all

package mmcguire;

import ca.morganmcguire.McMonitorServer;
import javax.xml.ws.WebServiceRef;
import javax.xml.ws.BindingProvider;

/**
 *
 * @author Morgan
 */
public class Main {
@WebServiceRef(wsdlLocation = "http://morganmcguire.ca/mcmonitor/mcmonitorserver.asmx?WSDL")
    private McMonitorServer service = new McMonitorServer();

    public static mmcguire.Main program;
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        program = new mmcguire.Main();
    }

    public Main()
    {
        System.out.println("Morgan McGuire");
       
        try
        {
            ca.morganmcguire.McMonitorServerSoap port1 = service.getMcMonitorServerSoap();

            ((BindingProvider)port1).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
           
            System.out.println(port1.lockedSessionHitCounter());
            System.out.println(port1.lockedSessionHitCounter());
            System.out.println(port1.login("Morgan", "smorgs"));
            System.out.println(port1.lockedSessionHitCounter());
            System.out.println(port1.lockedSessionHitCounter());
            System.out.println(port1.printInfo());
        }
        catch(java.lang.ClassCastException ex)
        {
            System.err.println("error: " + ex.getMessage());
        }
    }


}

User avatar
burley
Human-Cyborg Relations
Posts: 441
Joined: Tue Sep 27, 2011 2:37 pm
Location: Calgary
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby burley » Tue Nov 19, 2013 8:42 am

What is the error you get?
Brian Burley
403-282-7335 ext. 6003
support@phidgets.com

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Sat Nov 23, 2013 10:10 am

The errors are class definitions.

So the problem I'm having is, apparently JAX-WS and all those web service functions all work on java 1.6, but not on java 1.5?

When I try to run my project in netbeans it shows me:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

However if I compile it to java 1.7 it works fine. However it still will not run on the SBC.

I think I need a light weight version of web services that will work on java se 5 (java 1.5)


It's also possible i'm doing something wrong... I'm not too sure. has anyone tried to consume a webservice with the SBC yet?

MarkS
Phidgetly
Posts: 39
Joined: Sat May 15, 2010 8:37 am
Location: Southeast Pennsylvania USA
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby MarkS » Sat Nov 23, 2013 3:42 pm

If you have an SBC3, you could try updating the SBC to Java 1.7. Log into your SBC with SSH then at the prompt enter:

Code: Select all

apt-get install openjdk-7-jre-headless
You can also do this on an SBC2, but I think you need to update the OS to Debian 7 first.
Link: EcoSteam - Residential Steam Boiler Control using Phidgets
"Bringing 21st century automation to a 19th century home"

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Sat Nov 23, 2013 3:47 pm

I had a feeling I was going to be out of luck. I own the very first revision. SBC1

Does that mean I need to upgrade?

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Need Help with SBC Java Version

Postby morgan » Thu Feb 27, 2014 11:52 am

So, I've been stuck on this for a while... Is there any way to update my SBC (Original Release P/N: 1070 - 0 ) to Java 1.6, to be able to take advantage of webservices??

or like the above posts say, would i need to get myself an SBC3 in order to have the ability to update. I'm not sure if it's possible, before i figure out how it's done...

I can ssh putty into the unit, I just don't know how it's done, or if it's possible.

Can anyone give me some help on this??

Thanks,

Morgan

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

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby Patrick » Thu Feb 27, 2014 2:50 pm

You can't upgrade the Java version on SBC1.

-Patrick

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Thu Feb 27, 2014 5:02 pm

Anyone want to buy an old phidget?

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Fri Feb 28, 2014 12:35 am

If I need to purchase an SBC3, does it come with the version of java i need? or will i need to upgrade it?

Morgan

morgan
Phidgetly
Posts: 44
Joined: Sun Nov 28, 2010 4:34 pm
Contact:

Re: SBC Programming (JAVA) - Consume A Simple WebService

Postby morgan » Sun Mar 02, 2014 9:45 pm

What is the latest version of java that can be installed on the SBC3? What version does it come with?

I will need to use 1.6 at a minimum.

Thanks!
Looks like I will be buying a new toy soon.


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest