| Version 9 (modified by dtea, 6 years ago) |
|---|
The contract between the framework and one observer is composed of two files located on observer side :
- observer.wadl
- observer.rdf
To learn more : http://www.w3.org/QA/Tools/Unicorn/contract/
observer.wadl
This file describes the communication protocol between an observer and the framework who wants to use it. It defines all communication methods with their parameters and values allowed.
- Step 1 :
Write an XML header, root tag called application and define XML namespace attributs used.
<?xml version="1.0" encoding="utf-8"?> <application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://research.sun.com/wadl wadl.xsd" xmlns="http://research.sun.com/wadl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:uco="http://www.w3.org/unicorn/observationresponse"> ... </application>
- Step 2 :
In this part, we are going to define severals ressources of our observer.
In our case, we have just one resource, calculator.php, based on http://localhost/ (Full path of our observer will be http://localhost/calculator.php).
<?xml version...?>
<application...>
<resources base="http://localhost/">
<resource uri="calculator.php">
...
</resource>
</resources>
</application>
- Step 3 :
Now, we have to define methods of our observer.
There is two attributs for tag method :
- name : GET or POST.
- id : method's key name. We'll use this id in observer.rdf.
In our case, there is just one method. It takes 3 parameters (of which two are optional).
- uri : path of a file which contains some simple arithmetic operations.
- x2 : it's a complex type to multiply results by 2. We'll describe this more in details later.
- xn : to multiply results by n.
<method name="GET" id="CalculatorGET">
<request>
<query_variable name="uri" />
<query_variable name="x2" type="tX2"/>
<query_variable name="xn"/>
</request>
</method>
- Step 4 :
In step 3, we have defined a parameter "x2" with "tX2" type.
Only two values are possible for this parameter : 0 or 1.
If 1, results will be multiply by 2.
So, we are going now to definie a schema for our new type "tX2.
<xs:schema>
<xs:element name="tX2">
<xs:complexType>
<xs:choice>
<xs:element name="0" />
<xs:element name="1" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
You can see full observer.wadl here.
