Recent Changes - Search:


This section describes the procedure to implement client/applications subscribed to sensors managed by USN (Sensor Enabler). Applications subscribed to a sensor will be notified of events such as new observations and measurements, etc.

This manual provides instructions for JEE developers using Eclipse.

== Requirements: ==

JDK 1.5 or later

Eclipse for JEE developers

Ant version 1.6.5 or higher

Apache Tomcat (version 6)


First of all you will need to setup your Eclipse to use Tomcat and Axis2 home directories. To do that, go under Window->Preferences.

For setting up Tomcat click on Server->Runtime Environments and click Add...

Under Apache select the Tomcat version you have previously installed on your machine and click Next.

Under Tomcat installation directory browse the home folder of your Tomcat installation and click Finish.

The next step is to configure the Axis2, go again to Window->Preferences, select WebServices?->Axis2 Preferences and specify the home directory of your Axis2 installation. Finally click on Apply and OK.

Both Tomcat and Axis2 are now configured in your Eclipse installation. The next step is to create the project, go under File->New->Other... under Web select Dynamic Web Project and click Next.

Write a project name, set the target runtime to the Apache Tomcat version you have and set the Dynamic web module version to 2.5. On the Configuration click on Modify...

Select the Axis2 Web Services and click Save As... giving a name to this new configuration. Click on Next.

The Next step is to set the source and output folders for the project. In this case we will use the default configuration, so click Next.

[[The final step is to configure the web module settings we will use also the default configuration, with the Context root with the name of the project and the content directory is WebContent?. Click on Finish.

The new SmartSantanderServiceSkeleton? is now created.

The first step is to create a new folder inside the project called resources and place all the wsdl and xsd files of the UNICA platform.

Now that we have the web service description files in the project we will generate the web service code for some of the descriptions. For that right click on the project name and select New->Other...

Under Web Services select Web Service and click Next.

On the Web Service type select “Top down Java Bean Web Service” and browse the wsdl file for the notification service under the project resources folder. Then Click on the Server runtime.

On Server runtime select the Tomcat Server with the version of Tomcat you have and on the Web service runtime select Apache Axis2, click OK. Click Next.

Select the Generate an interface for the skeleton and generate all types for all elements referred by schemas and click on Next.

Finally click on Start server.

You should get some output on the Console, click Finish. Your web service should be now running. 16-03-2011 04:05:15 org.apache.coyote.AbstractProtocolHandler? start INFO: Starting ProtocolHandler? http-apr-8080? 16-03-2011 04:05:15 org.apache.coyote.AbstractProtocolHandler? start INFO: Starting ProtocolHandler? ajp-apr-8009? 16-03-2011 04:05:15 org.apache.catalina.startup.Catalina start INFO: Server startup in 40502 ms To check that the service is correctly running go to the Web Content folder->axis2-web right click on the index.jsp file and select Run As...->Run On Server.

Select the server that is currently running and click Next.

Make sure your project resources are under the Configured list and click Finish.

Apache’s page will appear, click on Services.

The M2MNotificationService should appear in the Services page.

Repeat the same process of creating a web service but this time for the M2MSubscriptionResponse service and check that you now have to services deployed.

Finally we need to create a client for the M2MSubscriptionService, for that right click on the project name and select New->Other... This time select under Web Services the Web Service Client and click on Next.

Browse the Subscription service wsdl file and select the Tomcat version and Axis2 as the service runtime. Click on Next.

Finally click on Finish.

The web service client code is now generated. The next step is to code the notify method of the notification service in the M2MNotificationServiceSkeleton and the subscription methods in the M2MSubscriptionResponseServiceSkeleton (see the attached code). Include also the and sources in your project and finally include also the file under resources folder of your project and edit the properties of uriSubscribeResponse and uriNotify adding the endpoints of both of the services:


SE.uriNotify= Now we just need to run the Start your Tomcat server with the notification and subscription services. Then go to the and right click on it. Select Run As->Run Configurations.

On the program arguments add the path to the file and click on Run.

You should get the following output: SubscriptionCLI: uriSubscribeResponse: subscribeObservation:AppPrueba service:ServicioPrueba uriNotify: seconds:0 original:false priority:1 xpath:/sos:RegisterSensor [INFO]

Attach:eclipse1.png Attach:eclipse2.png Attach:eclipse3.png Attach:eclipse4.png Attach:eclipse5.png Attach:eclipse6.png Attach:eclipse7.png Attach:eclipse8.png Attach:eclipse9.png Attach:eclipse10.png Attach:eclipse11.png Attach:eclipse12.png Attach:eclipse13.png Attach:eclipse14.png Attach:eclipse15.png Attach:eclipse16.png Attach:eclipse17.png Attach:eclipse18.png Attach:eclipse19.png Attach:eclipse20.png Attach:eclipse21.png Attach:eclipse22.png Attach:eclipse23.png Attach:eclipse24.png Attach:eclipse25.png Attach:eclipse26.png Attach:eclipse27.png Attach:eclipse28.png Attach:eclipse29.png

Edit - History - Print - Recent Changes - Search
Page last modified on December 02, 2011, at 03:46 PM