Aufruf eines Profils mit Eingangsagent HTTP(S)
Profile mit einem HTTP(S)-Eingangsagenten werden per HTTP-Request aufgerufen.
Aufruf mit einem Java-Programm
Das folgende Listing zeigt den Quellcode für ein Java-Programm, das ein Profil mit einem Eingangagenten des Typs HTTP(S) aufruft. Die gesendeten Daten sind im CSV-Format.
import java.io.BufferedInputStream;import java.io.DataOutputStream;import java.io.InputStream;import java.net.HttpURLConnection;import java.net.URL;//Simple example to trigger profile with an HTTP(S) Input Agentpublic class TestHttpAgent {//Connect to Lobster_data HTTP(S) server and trigger profilepublic static void main (String[] args) {try {//Parameters to match correct profile.String params = "?param1=value1¶m2=value2¶m3=value3¶m4=value4";//Create Connection to Lobster_data HTTP serverURL url = new URL("http", "localhost", 80,"/dw/Request/example" + params);HttpURLConnection con = (HttpURLConnection)url.openConnection();con.setRequestProperty("Content-Type", "");//Use POST methodcon.setDoOutput(true);con.connect();//Input data for profileDataOutputStream out = new DataOutputStream(con.getOutputStream());out.writeBytes("value11 , value12 , value13\n"+ "value21, value22, value23\n"+ "value31, value32, value33");//Read and print responseInputStream in = con.getInputStream();BufferedInputStream bufIn = new BufferedInputStream(in);int len = 0;byte[] response = new byte[100];while (len >= 0) {len = bufIn.read(response);if (len > 0)System.out.print(new String(response, 0,len));}} catch (Exception ex) {ex.printStackTrace();} finally {//Cleanupin.close();out.close();}}}Aufruf per Browser
Eine andere Möglichkeit den Agenten anzusprechen, ist ein Dateiupload über einen Browser. Dem Benutzer wird ein HTML-Formular zur Verfügung gestellt, über das er seine Daten an Lobster_data senden kann. Die folgende Abbildung zeigt, wie ein solches Formular aussehen kann.
Das folgende Listing zeigt den HTML-Quellcode zum Formular.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html401/loose.dtd"><html> <head> <title>Example HTML</title> </head> <body> <p align="center"><font size="8">Example to call a profile</font></p> <p> </p> <form name="formular" action="http://localhost/dw/Request/example" enctype="multipart/form-data" method=post> <p align="center"> <input type="submit" value="send"> <input type="file" name="upload"> <input type="hidden" name="param1" value="value1"> <input type="hidden" name="param2" value="value2"> <input type="hidden" name="param3" value="value3"> <input type="hidden" name="param4" value="value4"> <p> </form> </body></html>