Datum Technologie Entwicklung Werkzeug Übung Grundlagen 23.10.30 1 Überblick Ant Kompilieren 30.10.03 2 WLAN, BT Eclipse Projektverwaltung 06.11.03 3 GSM Eclipse Debugging 13.11.03 4 WAP, WML, WMLS XML Nokia Toolkit WML, WMLS 20.11.03 5 WAP, SMS, MMS XML JAVA mobil 27.11.03 6 Einführung J2ME J2ME Toolkit Erste Schritte 04.12.03 7 MIDP 1.0 GUI Grafik 11.12.03 8 HTTP / Sockets RMS+IO POSE RMS+IO 18.12.03 9 MIDP 2.0 Media+Game Projektvergabe Game Vernetzte Systeme 08.01.04 - - - - 15.01.04 10 Einführung Netzwerke Servlet Apache / Tomcat Projektarbeit 22.01.04 11 Beispiele Servlets SMS / LBS Kannel / Tomcat Projektarbeit 29.01.04 12 Peer-to-Peer Cocoon Projektarbeit 05.02.04 13 Präsentationen 12.02.04 14 Präsentationen 1
Java Mobile App. Designs 3-Tier Architecture Client Layer Application Layer Database Layer Beispiel MIDlet, JSP, J2SE Servlet, EJB SQL DB Client Server Presentation Tier Business Tier Data Tier MIDlet Servlet, JAXB Xindice XML DB Client Server 2
m-commerce Architecture Back-End Tier Middleware Web Tier Client Tier DB: Oracle, Mainframe, EIS App. Server, LDAP Server, EJB, Mail Server, Cal Server Web Server, JSP, Servlets, Beans MIDlet, WML/XHTML 3
Beispiele für Servlet-Einsatz 1. Nanosim Servlet als Middleware, die zwischen einem Datenerfassungssystem und mobilen Clients vermittelt. Datenstrom wird in Bilddaten verwandelt Ereignisstrom bidirektional für Parameter und Befehle 2. UMP: university mobile portal Servlet (eigtl. Cocoon Action) verwaltet verschiedene I/O-Kanäle und Datenbanken. I/O-Schnittstellen sind SMS, Email und HTML-Formulare. Kannel SMS Gateway 4
MIDlet - Servlet Beispiel Nanosim Messdaten von laufenden Messungen oder von Simulatoren von Rastersondenmikroskopen auf dem Mobilgerät visualisieren und Messungen steuern. Problem: kontinuierliche Datenströme spezielles Datenformat grosse Datenmengen Zweiweg Kommunikation für Steuerung Lösung: Servlet als Datenfilter, schickt PNG zum MIDlet HTTP Parameter als zweiweg Übertragung 5
Raster-Kraft-Mikroskop: Das Abtast- Prinzip 1nm = 10-9 m = Millionstel Millimeter Nanos :[griech.] der Zwerg Rasterkraftmikroskop 6
Friction Simulator Nano-World 7
1. Beobachten des Experiments auf dem PDA 8
2. Kontrollieren der experimentellen Parameter 9
3. Steuern des Experiments Änderung des Messbereichs 10
4. Benachrichtigen von Team- ENTWICKLUNG Kollegen 11
Nanosim Architektur Internet Air Mobile Device 1 SMS Receiver LAN Mobile Device 2 SMS Receiver Experiment Middleware Layer (Servlet) Notification Management SMS Gateway SMS Mobile Thin Client (MIDlet) Notification Button SMS Receiver Command Command Transformer Middleware Commands HTTP Request/Response Command Screen Raw Data TCP/IP Filter Image Preprocessor PNG Generator GPRS Gateway GPRS Image Commands Image Screen 12
Ein echtes fernkontrolliertes ENTWICKLUNG Experiment... AFM Drehtisch x z φ y 13
SMS - Servlet Beispiel SMS Dienste Schicken Sie ein SMS mit dem Inhalt PIN START an die Nummer 079 290 79 91, um sich anzumelden, PIN STOP, um sich abzumelden und z.b. PIN suche alte wohnung, um eine Anzeige aufzugeben. Problemstellung: Automatischer Empfang von SMS Umleitung anhand eines Keywords (z.b. PIN) Verarbeitung der SMS durch ein Servlet + generieren einer Antwort-SMS Verschicken der Antwort-SMS 14
SMS-Dienst SMS-Empfänger GSM-Modem oder Mobiltelefon (AT-fähig, (Hayes Modem Command Set)) Verbindungs-Daten-Kabel SMS-Gateway-Server Open Source Lösung Kannel Tomcat Servlet-Container Servlet, um eingehende SMS zu verarbeiten Gateways für abgehende SMS uni-intern Switch-Gateway (Email => SMS) oder via Kannel (String => SMS) oder via Web-SMS-Gateway (z.b. www.skymo.com, HTTP => SMS) 15
Kannel Open Source WAP and SMS gateway läuft unter Linux / Cygwin www.kannel.org LAN Internet SIM Phone Kannel Gateway Server 16
Kannel SMS-Service Config Beispiele: group = sms-service keyword = news omit-empty = 1 get-url = "http://131.152.85.65:8079/mobile/ News?num=%p&msg=%r&kan=1" max-messages = 0 andere Konfigurationen: send-sender = 1 max-messages = 5 file= /var/kannel/antwort-sms.txt text= Dies ist eine Standard-Antwort. exec= pwd group = sms-service keyword = www get-url = "http://%s" Parameters, Escape codes: %k Keyword %S second word %r Rest der Nachricht %t Zeit %p Telefon-Nummer Absender etc. 17
Kannel Input SMS SMS : Pin testing an +41792907991 2004-01-20 11:04:19 [4] INFO: Starting to service <Pin testing> from <41793726752> to <1234> 2004-01-20 11:04:19 [9] DEBUG: HTTP: Opening connection to `131.152.85.65:8079' (fd=28). 2004-01-20 11:04:19 [9] DEBUG: Socket connecting 2004-01-20 11:04:19 [8] DEBUG: Get info about connecting socket 2004-01-20 11:04:19 [8] DEBUG: HTTP: Sending request: 2004-01-20 11:04:19 [8] DEBUG: Octet string at ba718: 2004-01-20 11:04:19 [8] DEBUG: len: 121 2004-01-20 11:04:19 [8] DEBUG: size: 122 2004-01-20 11:04:19 [8] DEBUG: immutable: 0 2004-01-20 11:04:19 [8] DEBUG: data: 47 45 54 20 2f 6d 6f 62 GET /mob 2004-01-20 11:04:19 [8] DEBUG: data: 69 6c 65 2f 50 69 6e 3f ile/pin? 2004-01-20 11:04:19 [8] DEBUG: data: 6e 75 6d 3d 34 31 37 39 num=4179 2004-01-20 11:04:19 [8] DEBUG: data: 33 37 32 36 37 35 32 26 3726752& 2004-01-20 11:04:19 [8] DEBUG: data: 6d 73 67 3d 74 65 73 74 msg=test 2004-01-20 11:04:19 [8] DEBUG: data: 69 6e 67 26 6b 61 6e 3d ing&kan= 2004-01-20 11:04:19 [8] DEBUG: data: 31 20 48 54 54 50 2f 31 1 HTTP/1 2004-01-20 11:04:19 [8] DEBUG: data: 2e 31 0d 0a 48 6f 73 74.1..Host 2004-01-20 11:04:19 [8] DEBUG: data: 3a 20 31 33 31 2e 31 35 : 131.15 2004-01-20 11:04:19 [8] DEBUG: data: 32 2e 38 35 2e 36 35 3a 2.85.65: 2004-01-20 11:04:19 [8] DEBUG: data: 38 30 37 39 0d 0a 55 73 8079..Us 2004-01-20 11:04:19 [8] DEBUG: data: 65 72 2d 41 67 65 6e 74 er-agent 2004-01-20 11:04:19 [8] DEBUG: data: 3a 20 4b 61 6e 6e 65 6c : Kannel 2004-01-20 11:04:19 [8] DEBUG: data: 2f 63 76 73 2d 32 30 30 /cvs-200 2004-01-20 11:04:19 [8] DEBUG: data: 33 30 35 32 37 0d 0a 0d 30527... 2004-01-20 11:04:19 [8] DEBUG: data: 0a. 2004-01-20 11:04:19 [8] DEBUG: Octet string dump ends. 18
Kannel Output SMS Kannel 2004-01-20 11:04:41 [8] DEBUG: HTTP: Status line: <HTTP/1.1 200 OK> 2004-01-20 11:04:41 [8] DEBUG: HTTP: Received response: 2004-01-20 11:04:41 [8] DEBUG: Octet string at ba988: 2004-01-20 11:04:41 [8] DEBUG: len: 489 2004-01-20 11:04:41 [8] DEBUG: size: 490 2004-01-20 11:04:41 [8] DEBUG: immutable: 0 2004-01-20 11:04:41 [8] DEBUG: data: 58 2d 43 6f 63 6f 6f 6e X-Cocoon (...) 2004-01-20 11:04:41 [8] DEBUG: data: 0a 3c 2f 62 6f 64 79 3e.</body> 2004-01-20 11:04:41 [8] DEBUG: data: 0a 3c 2f 68 74 6d 6c 3e.</html> 2004-01-20 11:04:41 [8] DEBUG: data: 0a. 2004-01-20 11:04:41 [8] DEBUG: Octet string dump ends. 2004-01-20 11:04:41 [5] INFO: No reply sent, denied. Servlet löst ein Email aus: To: 0793726752@sms.switch.ch Subject: pin Body: 0793726752-20/01/2004 11:02:41-testing SMS erhalten von 47587: pin@stud.unibas.ch (pin) 0793726752-20/01/2004 11:02:41-testing 19
Kannel Status 20
university mobile portal UMP ormationsdrehscheibe für mobile Kleingeräte ENTWICKLUNG attinger, M. Guggisberg, and H. Burkhart ience Department / sel, http://eudora.ifi.unibas.ch:8079/mobile/portal Klingelbergstr. 50, CH-4056 Basel, Switzerland an Wattinger christian.wattinger@unibas.ch http://fgb.informatik.unibas.ch/fgb SMS Web Umwandlung Email ionen können über die verschiedenen Kanäle (SMS, Email, ite) eingegeben oder angefordert werden. Sie werden dann m situations- und/oder benutzerdefinierten Kanal an die ger ausgegeben. Weitere Kanäle wie WAP, MMS, J2ME modular hinzugefügt werden. WAP etc. Mobile Technologien ump: university mobile portal Eine Informationsdrehscheibe für mobile Kleingeräte C. C. Kern, C. C. Wattinger, M. M. Guggisberg, and H. H. Burkhart Computer Science Department //, Klingelbergstr. 50, 50, CH-4056 Basel, Switzerland Kontakt: Christian Wattinger christian.wattinger@unibas.ch http://fgb.informatik.unibas.ch/f 21
ump Setup Kannel Gateway Tomcat Web Interface SMS Receiver COMM HTTP UMP Database Mailer SMTP Email SMS Email Clients SMS Clients Antenne Switch Email => SMS Gateway 22
) eingegeben oder angefordert werden. Sie werden dann situations- UMP Architektur und/oder benutzerdefinierten Kanal an die r ausgegeben. Weitere Kanäle wie WAP, MMS, J2ME odular hinzugefügt werden. Technologien: SMS-Komponente: Kern-Komponente: Server-Software: Datenbank: Kannel Open Source SMSC Cocoon Action Tomcat Servlet Container Xindice XML-Database ENTWICKLUNG Dienste: - virtuelles Anschlagbrett - News-Service - Erinnerungsdienst modular erweiterbar Schicken Sie ein SMS mit dem Inhalt PIN START an die Nummer 079 290 79 91, um sich anzumelden, PIN STOP, um sich abzumelden und z.b. PIN suche alte wohnung, um eine Anzeige aufzugeben. 23
Neue Welt 24
Neue Welt 25
Neue Welt 26
Web Service für mobile Geräte 27
Web services Java TM Web Services Developer Pack 1.3 The Java API for XML Processing (JAXP) The Java API for XML-based RPC (JAX-RPC) SOAP with Attachments API for Java (SAAJ) The Java API for XML Registries (JAXR) The Java Architecture for XML Binding (JAXB) Web Service Tutorial: http://www.heise.de/ix/artikel/2002/11/140/ Lars Röwekamp 28
Aufgabe des Servers Bereitstellung von Inhalten im richtigen Format Session Verwaltung Authentifizierung & verschlüsselte Kommunikation 24h, 365 Tage verfügbar (Stabilität, Robustheit) - Einfache Installtion oder Updates von Diensten - Konfiguration nach Firmen eigenen Bedürfnisse 29
Dokumentation J2EE jwsdp-1.3/docs/api/index.html 30
Methode zur ENTWICKLUNG Installation eines Servlets Eine Webanwendung kann auf einem Server installiert werden, indem das WAR-File in den webapps Ordner kopiert wird. WAR-File Konfiguration server.xml <Host... appbase="webapps... livedeploy="true"... unpackwars= true" name="localhost"> htttp://jakarta.apache.org 31
File Struktur einer Webanwendung JaxWebApp/ index.html images/ company.jpg people.jpg WEB-INF/ web.xml classes/ jax/ lib/ HelloWorld.class counter.class core.jar Name HTML Seiten Konfiguration Class Files jar Files 32
WAR web application archive ENTWICKLUNG WAR => JAR-File Struktur einer Webanwendung Bsp: mit ANT <property name="war.dist" value= lekt3.war"/> <jar jarfile="${war.dist}" basedir="${build.dir}"/> Kommando Zeile: jar -cfv lekt3.war PATH/build 33
jar Falle 34
Konfiguration http://..index.html Get Request Webserver Servlet? Servlet Container Response welches Servlet? doget() 35
Konfiguration Webserver https://spc.swisspostnet.com/servlet/dispatchingservlet http://hostname/context/webapplication Servlet Container Web Anwendung server.xml Request Response web.xml Context Session 36
Tomcat Servlet Container Konfiguration (web.xml; server.xml) server.xml => web.xml => Konfiguration des Servlet Kontainers Konfiguration einer Webanwendung 37
server.xml <Server> JAVA VM <Service> Sammlung mehrer Connectors <Connector /> Endpunkt von REQ und RES <Engine> Repräsentiert Catalina Objekt <Host> Virtueller Host <Context> Definiert die individuellen Webapplikationen </Context> </Host> </Engine> </Service> </Server> 38
Admin Tool Ein Webservice wird im Servletcontainer mittels eines Context Knoten angesteuert. Die Angaben der Konfiguration des Servletcontainers stehen in der server.xml Datei. 39
40
41
Valves Values for the Pattern Attribute ENTWICKLUNG %a - Remote IP address %A - Local IP address %b - Bytes sent, excluding HTTP headers, or '-' if zero %B - Bytes sent, excluding HTTP headers %h - Remote host name (or IP address if resolvehosts is false) %H - Request protocol %l - Remote logical user name from identd (always returns '-') %m - Request method (GET, POST, etc.) %p - Local port on which this request was received %q - Query string (prepended with a '?' if it exists) %r - First line of the request (method and request URI) %s - HTTP status code of the response %S - User session ID %t - Date and time, in Common Log Format %u - Remote user that was authenticated (if any), else '-' %U - Requested URL path %v - Local server name 42
Log 43
launcher.server.log Jan 21, 2004 10:41:19 AM org.apache.xindice.core.database setconfig INFO: Database points to /Users/guggisberg/developer/jwsdp-1.3/registry-server/Xindice/./db Jan 21, 2004 10:41:19 AM org.apache.xindice.server.xindiceservlet init INFO: Database successfully started Jan 21, 2004 10:41:19 AM org.apache.catalina.core.standardhostdeployer install INFO: Installing web application at context path /jsp-examples from URL file:/users/guggisberg/developer/ jwsdp-1.3/webapps/jsp-examples ContextListener: attributeadded('com.sun.faces.configbase', 'com.sun.faces.config.configbase@366c17') Jan 21, 2004 10:41:20 AM org.apache.catalina.core.standardhostdeployer install INFO: Installing web application at context path from URL file:/users/guggisberg/developer/jwsdp-1.3/ webapps/root Jan 21, 2004 10:41:21 AM org.apache.catalina.core.standardhostdeployer install INFO: Installing web application at context path /servlets-examples from URL file:/users/guggisberg/developer/ jwsdp-1.3/webapps/servlets-examples ContextListener: attributeadded('com.sun.faces.configbase', 'com.sun.faces.config.configbase@50ceb8') Jan 21, 2004 10:41:21 AM org.apache.coyote.http11.http11protocol start INFO: Starting Coyote HTTP/1.1 on port 8080 Jan 21, 2004 10:41:22 AM org.apache.catalina.startup.catalina start INFO: Server startup in 46702 ms 44
access_log.2004-01-21.txt 127.0.0.1 - - [21/Jan/2004:10:41:21 +0100] "GET /admin/ HTTP/1.1" 302-127.0.0.1 - - [21/Jan/2004:10:41:22 +0100] "GET /admin/frameset.jsp HTTP/1.1" 200 2465 127.0.0.1 - - [21/Jan/2004:10:41:22 +0100] "GET /admin/tree-control-test.css HTTP/1.1" 200 325 127.0.0.1 - - [21/Jan/2004:10:41:22 +0100] "GET /admin/admin.css HTTP/1.1" 200 2056 127.0.0.1 - - [21/Jan/2004:10:41:23 +0100] "GET /admin/images/loginbackgroundtile.gif HTTP/1.1" 200 1235 127.0.0.1 - - [21/Jan/2004:10:41:23 +0100] "GET /favicon.ico HTTP/1.1" 404 977 127.0.0.1 - - [21/Jan/2004:10:41:23 +0100] "GET /admin/images/login.jpg HTTP/1.1" 200 18404 127.0.0.1 - - [21/Jan/2004:10:42:08 +0100] "POST /admin/j_security_check HTTP/1.1" 302-127.0.0.1 - guggisberg [21/Jan/2004:10:42:08 +0100] "GET /admin/frameset.jsp HTTP/1.1" 200 908 127.0.0.1 - guggisberg [21/Jan/2004:10:42:11 +0100] "GET /admin/admin.css HTTP/1.1" 200 2056 127.0.0.1 - guggisberg [21/Jan/2004:10:42:11 +0100] "GET /admin/tree-control-test.css HTTP/1.1" 200 325 127.0.0.1 - guggisberg [21/Jan/2004:10:42:11 +0100] "GET /admin/blank.jsp HTTP/1.1" 200 544 45
46
Dynamische Konfiguration des ENTWICKLUNG Servletcontainers Web Application Manager List http://<host>:8080/manager/list Install http://<host>:8080/manager/install? path=/mywebapp&war=file:/path/to/mywebapp http://<host>:8080/manager/install? path=/mywebapp& war=jar:file:/path/to/mywebapp.war!/ Reload http://<host>:8080/manager/reload?path=/mywebapp Remove http://<host>:8080/manager/remove?path=/mywebapp 47
Konfiguration Webanwendung <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>helloworld</servlet-name> <servlet-class>jax.helloworld</servlet-class> </servlet> <servlet-mapping> <servlet-name>helloworld</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping> </web-app> 48
Login Authentication ENTWICKLUNG HTTP Basic authentication <login-config> <auth-method>basic</auth-method> </login-config> ---------------------------------- <?xml version='1.0'?> <tomcat-users> <role rolename="manager"/> <role rolename="admin"/> <role rolename="loginuser"/> <user username="your_name" password="your_password" roles="admin,manager,loginuser"/> </tomcat-users> 49
Server Error HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.servletexception: Name jdbc is not bound in this Context at jsp.createservlet.doget(unknown Source) at javax.servlet.http.httpservlet.service(httpservlet.java:740) at javax.servlet.http.httpservlet.service(httpservlet.java:853) at org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:247) at org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:193) at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:260) at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:646) at org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:483) at org.apache.catalina.core.containerbase.invoke(containerbase.java:995) at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191) at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:646) at org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:483) at org.apache.catalina.core.containerbase.invoke(containerbase.java:995) at org.apache.catalina.core.standardcontext.invoke(standardcontext.java:2349) at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:180) HTTP Status 500 - at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:646) at org.apache.catalina.valves.errordispatchervalve.invoke(errordispatchervalve.java:170) type at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:644) Exception report at org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:171) message at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:644) at org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:483) at org.apache.catalina.core.containerbase.invoke(containerbase.java:995) at org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:174) from at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:646) fulfilling this request. at org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:469) at org.apache.catalina.core.standardpipeline$standardpipelinevalvecontext.invokenext(standardpipeline.java:644) exception at org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:483) at org.apache.catalina.core.containerbase.invoke(containerbase.java:995) at org.apache.coyote.tomcat4.coyoteadapter.service(coyoteadapter.java:223) at org.apache.coyote.http11.http11processor.process(http11processor.java:405) description The server encountered an internal error () that prevented it javax.servlet.servletexception: Name jdbc is not bound in this Context 50
Server Error HTTP Status 500 -... exception... java.lang.nullpointerexception org.apache.catalina.core.standardpipeline$standardpi pelinevalvecontext.invokenext(standardpipeline.jav a:644)... 51
Location API for Java Version 1.0 Proposed Final Draft 0.6 JSR 179 Expert Group jsr-179-comments@jcp.org ENTWICKLUNG GPS (Global Positioning System) E-OTD (Enhanced Observed Time Difference) SIMTK (Subscriber Identity Module Toolkit) COO (Cell of Origin) AOA (Angle of Arrival) TDOA (Time Difference of Arrival) LPM (Location Pattern Matching) agps (assisted GPS) 52
JSR179 Location API for J2ME ENTWICKLUNG 53