Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
[Info]
Assignment 6
Write for a correlator for a predefined process. Hints:
- Use as much pieces from your REST example / XML data as possible (re-factoring!)
- Write a REST service which generates random orders and returns them as JSON (min 4 parts).
- Write a REST Service which generates a progress report for the process of the order and returns it as a JSON.
- Write a REST Service which simulates a inventory management for parts.
Assignment 6a - Preparation (2 points)
You manage an inventory (for your topic). Answer the following questions:
- Which are your parts (min 4 parts)?
- Which individual pieces do parts consist of (min 7 pieces)? (1 JSON file that describes the inventory, including numbers which describe the available amount - see example above)
- How does the order for a product look like? (min 4 parameters)? (1 JSON File that describes the order - see example ).
- A progress reports which consists of min 7 steps (1 JSON File that describes the progress - see example above).
Additionally: write three REST services, das describe above.
Submission
- 1 file progress.json.
- 1 file order.json.
- 1 file inventory.json.
- 1 file code.zip
MANDATORY AND VERY IMPORTANT: Register the rest services via «http://donatello.cs.univie.ac.at/tools_lehre/interop/2019/correlation_phase1/index.php».
Hints
- If the filenames are not correct, you will get no points.
- If you violate any rules you will get no points.
Assignment 6b - Correlation (10 points)
Write and register a correlation service via «http://donatello.cs.univie.ac.at/tools_lehre/interop/2019/correlation_phase2/index.php».
Implement the correlator logic: To create a process instance, change the process template, and instantiate (from file) it through «http://cpee.org/~demo/cpee-cockpit/».
How to change the process template:
- Change /testset/endpoints/teil1 to point to your part 1
- Change /testset/endpoints/teil2 to point to your part 2
- Change /testset/endpoints/teil3 to point to your part 3
- Change /testset/endpoints/teil4 to point to your part 4
- Change /testset/endpoints/progress to point to your progress report.
- Change /testset/attributes/info to point to contain YOUR NAME AND MATRIKELNUMMER.
When the correlator is called from the engine it should answer, that it wants to call back later.
- The reason for a callback is: i don't know NOW, what to answer.
<call id="a4" endpoint="correlation">
<parameters>
<label>"Warten auf Fortschritt"</label>
<method>:post</method>
<parameters>
<pid>data.pid</pid>
</parameters>
</parameters>
<finalize>data.progress = result["progress"]</finalize>
</call>
- For this activity the answer is not known; but you get progress updates in a certain time interval (e.g. every 5 seconds).
<finalize>data.progress = result["progress"]</finalize>
- This line tells you, that the CPEE expects a JSON object with key "progress". HOT TIP: Log all messages in the correlator to find out what is going on.
- Logging + Callback Example (can also be found via «http://wwwlab.cs.univie.ac.at/~stertzf9/callback/server.phps»)
<?php
include('rest_handle.php');
$rest = handleREST($_SERVER,$_GET);
//******* CPEE POST empfangen. CPEE kann auch GET PUT und DELETE Requests absetzen.
if ($rest->method=="POST"){
//******* Der Korrelator kann auch so loggen.
$fh = fopen("log.log","a");
//******* ALLE Header in ein File schreiben.
fwrite($fh,print_r(getallheaders(),true));
//******* Header damit die CPEE weiss, dass wir spaeter antworten.
header('CPEE_CALLBACK: true');
}
/*
Die Header wuerden so z.B. aussehen.
Sie brauchen [Cpee_callback]. Ein PUT Request auf diese Adresse laesst den Prozess weiterlaufen.
(
[Cpee_base] => http://cpee.org:9298
[Cpee_instance] => http://cpee.org:9298/194
[Cpee_callback] => http://cpee.org:9298/194/callbacks/22b728c475d6f70ec970ce0a130a22fa
[Cpee_activity] => a1
[Cpee_label] => Wir werden warten
[Cpee_attr_info] => ss
[Cpee_attr_modeltype] => CPEE
[Accept-Encoding] => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
[Accept] => *//*
[User-Agent] => Ruby
[Content-Type] => text/plain
[Content-Length] => 0
[Host] => wwwlab.cs.univie.ac.at
)
*/
?>
- In your correlator: save the callback url.
- PUT to the callback url, whenever a message arrives that is suitable. The instance should then go to state "finished".
<?
$opts = array('http' =>
array(
'method' => 'PUT',
'header' => 'Content-type: application/json',
'content' => JSON_DATA
)
);
$context = stream_context_create($opts);
$result = file_get_contents('http://...', false, $context);
exit;
?>
Submission
- 1 file process.xml. In the pro
- 1 file code.zip
DONT FORGET: change /testset/attributes/info.
MANDATORY AND VERY IMPORTANT: Register the rest services via «http://donatello.cs.univie.ac.at/tools_lehre/interop/2019/correlation_phase2/».
Hints
- If the filenames are not correct, you will get no points.
- If you violate any rules you will get no points.
- If you forgot to change /testset/attributes/info, you get zero points.
Letzte Änderung: 23.05.2019, 12:16 | 721 Worte