Subscribe to News

Xmpp Web Service for Total VideoConference - Development

Author : Despino4

From TechnologicalWiki

Jump to: navigation, search
Xmpp Web Service for Total VideoConferenceDevelopmentTestingReferences

Contents

[edit] Technology selected to develop the implementation

  • To develop the Web Service we have used the Java API for XML Web Services (JAX-WS) 2.0/2.1, JSR 224,which is an important part of the Java EE 5 platform. JAX-WS simplifies the task of developing web services using Java technology. It addresses some of the issues in JAX-RPC 1.1 by providing support for multiple protocols such as SOAP 1.1, SOAP 1.2, XML, and by providing a facility for supporting additional protocols along with HTTP. JAX-WS uses JAXB 2.0 for data binding and supports customizations to control generated service endpoint interfaces. With its support for annotations, JAX-WS simplifies web service development and reduces the size of runtime JAR files.
  • Our web service use the Smack API in order to manage the xmpp connections.Smack is an Open Source XMPP (Jabber) client library for instant messaging and presence. A pure Java library, it can be embedded into your applications to create anything from a full XMPP client to simple XMPP integrations such as sending notification messages and presence-enabling devices.
  • In this development it has been used another Java API that can make it easier to access XML documents: Java Architecture for XML Binding (JAXB). A Reference Implementation of the API is now available in the Java Web Services Developer Pack V 1.1. JAXB simplifies access to an XML document from a Java program by presenting the XML document to the program in a Java format. In our case, the XML document needed is the sent to the location server, having all the desired location information.We bind the schema (DTD file in this case) for the XML document into a set of Java classes that represents the schema.

[edit] Application structure

We have structured the application in the following java packages:

  • Org.vodafone.xmpp
  • Org.vodafone.osami.utilities
  • Org.vodafone.jaxb.osami.locserver

[edit] Understanding the function of each class

There is a brief explanation of the most important classes in the application

  • Package org.vodafone.xmpp
    • Xmpp.java: Represents the class implementing the desired method for this web service.In this case the method is called "sendRequest" and it has two input parameters called "to" and "request".
      The result of the invocation is a boolean value:
      • The result is true if the xmpp account recipient of the location message has answered us.
      • The result is false if we receive no response or if the response is not received within a period of time determined by a certain timer.
    • StopTimer.java:This class represents the timer which is started every time we send a request from the client xmpp.
    • ClientXmpp.java:Represents the xmpp client,using the Smack API in order to:
      1. Connecting/Logging the xmpp client.
      2. Sending the xml location file.
      3. Waiting in a loop for the response of the remote recipient.We stop the iteration if the timer StopTimer reaches the maximum time allowed.
      4. Disconnecting the xmpp client.
  • Package org.vodafone.jaxb.osami.locserver
    This package contains all the classes generated meanhile the binding of the xml schema (dtd file in this case).Binding a schema means generating a set of Java classes that represents the schema. All JAXB implementations provide a tool called a binding compiler to bind a schema (the way the binding compiler is invoked can be implementation-specific). For example, the JAXB Reference Implementation provides a binding compiler that you can invoke through scripts. If we are using NetBeans to develop the application we can bind the locserver.dtd schema using the binding compiler provided by the JAXB Reference Implementation meanwhile these sentences in the build.xml:
<target name="-pre-compile">
       <exec executable="${java.home}/../bin/xjc">
           <arg line="-p org.vodafone.jaxb.osami.locserver"/>
           <arg line="-d src/java"/>
            <arg line="-dtd web/schemas/locserver.dtd"/>
       </exec>
</target>
 
  • Package org.vodafone.osami.utilities
    • OsamiReportLocalizationData.java: This class uses the classes generated in the org.vodafone.jaxb.osami.locserver to obtain a well formed xml document which is sent by the xmpp client.This code is the responsible for doing the marshalling, where a JAXBContext object is created and the appropriate package that contains the classes and interfaces for the bound schema is specified.

[edit] Classes diagrams

This is the classes diagram of the org.vodafone.xmpp package:

This is the classes diagram of the org.vodafone.osami.utilities package:

This is the classes diagram of the org.vodafone.jaxb.osami.locserver package:

[edit] Setting configuration parameters

We need to add the following entries to the web.xml generated for the web service.These entries will be some configuration parameters needed for the performance of the application.These parameters are:

  • Domain: Domain used for the account used as xmpp client.
  • Port: Port of the xmpp server.
  • User: Identity of the xmpp user.This is the account name used as xmpp client by the code.
  • Password: Password of the xmpp account.
  • Timeout:This value is the maximum time to await for the reply from the recipient of messages sent by the xmpp client.
   <env-entry>
       <env-entry-name>domain</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>osami.tid.es</env-entry-value>
   </env-entry>
   <env-entry>
       <env-entry-name>port</env-entry-name>
       <env-entry-type>java.lang.Integer</env-entry-type>
       <env-entry-value>5222</env-entry-value>
   </env-entry>
   <env-entry>
       <env-entry-name>user</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>totalvideoconf_vf</env-entry-value>
   </env-entry
   <env-entry>
       <env-entry-name>password</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value>0s4m1vf</env-entry-value>
   </env-entry>
   <env-entry>
       <env-entry-name>timeout</env-entry-name>
       <env-entry-type>java.lang.Integer</env-entry-type>
       <env-entry-value>10</env-entry-value>
   </env-entry> 


[edit] Information sent by the xmpp client

The xmpp client sends a message to the server location which is a xml message like this:

       <osami type=loc>
       	<agent type="BT">
       		<id>08:00:69:02:01:FC</id>		# Agent's ethernet MAC address
       		<name>myDesktopPc</name>		# Agent's name
       	</agent>
       	<device range= true>				# Device enters agent's range
       		<id>00:22:15:6a:6f:b5</id>		# Device Bluetooth MAC address
       		<name>myAndroidMobile</name>		# Device name
       	</device>
       	<localization>
       		<name>myOffice</name>			# Name of the place where devices are detected
       		<coor>41.062786,-3.610841</coor>	# Geographical coordinates
       		<date>29/04/09 10:35:42</date>		# Time of detection
       	</localization>
       </osami>


This xml is validated against the following DTD file provided by Telefonica i+d:

<!ELEMENT osami (agent?, device?, localization?, user?, rule?)>
<!ELEMENT agent (id, name?)>
<!ELEMENT device (id, name?)>
<!ELEMENT localization (name?, coor?, date?)>
<!ELEMENT user (name, address)>
<!ELEMENT rule (id?, condition?, device?, user?, address?)>
<!ELEMENT condition (id|area|point|coor|remove)>
<!ELEMENT id (#PCDATA)> <!ELEMENT coor (#PCDATA)> <!ELEMENT name (#PCDATA)> <!ELEMENT address (#PCDATA)> <!ELEMENT date (#PCDATA)>
<!ATTLIST osami type (loc|req|att|det|rul|ans|eve) #REQUIRED> <!ATTLIST agent type (BT|WIFI|GPS) #REQUIRED> <!ATTLIST device range (true|false) #IMPLIED> <!ATTLIST rule remove (true) #IMPLIED>
Main Collaborators