Title: Pablo Antoln
1- Pablo Antolín
- Francisco Milagro
- TID
Java EDITION!!
2Application View
Windmeter
Disco Ball
Rain Sensor
Lamp
Fan
Phone
Thermometer
3Your assignment
- If temperature is above 20 degrees the DiscoBall
should be rotating. - When windspeed exceeds 2 the Light should flash 3
times. - Windspeed can be altered by turning on Fan in
front of Windmeter. - When leaving application Fan and DiscoBall should
be turned off.
41. Set up the environment
- Download Axis 1.4 (http//ws.apache.org/axis/)
and install it following the instruction provided
in the webpage. - We will use Eclipse as the IDE to create the
first Hydra application in Hydra - You can of course use any other IDE or text editor
52. Create a PHP project
- Create a new Java proyect and create a class for
your application.
- Add the axis libraries to the classpath of your
project
63. Web Service References
- You will use these endpoints to consume the
services - DiscoBall http//212.214.80.1618080/3/BasicSwitc
hWS - Fan http//212.214.80.1618080/4/BasicSwitchWS
- Light http//212.214.80.1618080/2/EnhancedSwitch
WS - Thermometer http//212.214.80.1618080/Thermomete
rWS - Windmeter http//212.214.80.1618080/WindmeterWS
74. Create the Java Client code using axis
- Open a command console and create the Java client
code for each service, providing the path to the
wsdl file -
- java -cp AXISCLASSPATH org.apache.axis.wsdl.WSD
L2Java -u http//212.214.80.1618080/3/BasicSwitc
hWS?wsdl
This will generate for you the client code.
Repeat this operation and copy the code generated
to your project.
84 Start coding
public class HydraForDummiesApp public static
void main(String args) throws
MalformedURLException, ServiceException,
NumberFormatException, RemoteException //Get
the services for each device IHydraThermometerWSSe
rvice thermometer new ThermometerWSLocator() .g
etBasicHttpBinding_IHydraThermometerWSService( ne
w URL("http//212.214.80.1618080/ThermometerWS"))
IHydraBasicSwitchWSService discoBall new
BasicSwitchWSLocator() .getBasicHttpBinding_IHydr
aBasicSwitchWSService( new URL("http//212.214.80
.1618080/3/BasicSwitchWS")) IHydraBasicSwitchWSS
ervice fan new BasicSwitchWSLocator() .getBasic
HttpBinding_IHydraBasicSwitchWSService( new
URL("http//212.214.80.1618080/4/BasicSwitchWS"))
IHydraWindmeterWSService windMeter new
WindmeterWSLocator() .getBasicHttpBinding_IHydraW
indmeterWSService( new URL("http//212.214.80.161
8080/WindMeterWS")) IHydraEnhancedSwitchWSServic
e light new EnhancedSwitchWSLocator() .getBasic
HttpBinding_IHydraEnhancedSwitchWSService( new
URL("http//212.214.80.1618080/2/EnhancedSwitchWS
"))
95 Finalise your Code
//Start coding the program //Get
temperature Double temperature
Double.parseDouble(thermometer.getIndoorTemperatur
e()) if (temperature gt 20) //Turn on
discoBall discoBall.turnOn() //Turn on the
fan fan.turnOn() //Check wind speed Double wind
Double.parseDouble(windMeter.getWindSpeed()) if
(wind gt 2) //Flash the light three
times light.flash(Short.parseShort("3")) //Tur
n off the fan and discoball discoBall.turnOff() f
an.turnOff()
106. View Application when Executing
http//hydra.cnet.se
- Run the application (Run -gt Java Application)
- Check that everything is working in the live
webcam
11Congratulations! You are now a Hydra Pro!