Web Services

Werbung
Web Services
JOHANNES KEPLER UNIVERSITY LINZ
Research and teaching network
Pratikum SWE 2 © Institut für Systemsoftware, Johannes Kepler Universität Linz
Web Services
Einführung
Web-Services in Java
JAXB
SOAP und WSDL
Zusammenfassung
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
2
Motivation
Integration heterogener, verteilter Systeme
 global verteilt
 unterschiedliche Programmiersprachen
 unterschiedliche APIs
B2C und B2B Anwendungen
Nutzung global verteilter Services
Beispiel: Travel Agent Service
entnommen aus:
Web Services Architecture Usage Scenarios,
W3C Working Group Note, 11 February 2004,
http://www.w3.org/TR/2004/NOTE-ws-arch-scenarios20040211/
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
3
Was sind Web Services?
Middleware for verteilte Anwendungen
Für Remote Procedure Calls (SOAP) und
Dokumenten-basierten Zugriff (RESTful)
Offener Standard basierend auf XML
Für lose gekoppelte Software-Services
Unabhängig von Programmiersprachen und Betriebssystemen
Mit Verwendung von existierenden Internet-Protokollen und ServerArchitekturen
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
4
Definition Web-Service (nach W3C)
durch eine URI identifizierbare Softwareanwendung
mit Schnittstellendefinition in XML
mit Interaktion auf Basis XML-basierter Nachrichten
und Nachrichtenaustausch über Internetprotokolle
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
5
Unabhängigkeit und Integration durch ...
SOAP
 XML-Standard für Nachrichtenaustausch
 unabhängig von Transportprotokoll
 unabhängig von Client- und Service-Implementierung: Java, .NET, Python, …
Web Services Description Language - WSDL (1.1)
 Interface-Beschreibung in XML
Kommunikation auf Basis existierenden Protokolle und
Serverarchitekturen
 HTTP und Web-Server
 SMTP und Mail-Server
 FTP und FTP-Server
Standardisierung (W3C)
 SOAP 1.2, WSDL 2.0
 Zusätzliche Protokolle basierend auf SOAP and WSDL
 Bindung an Protokollschicht (HTTP)
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
6
Web-Service-Infrastruktur
Web Container
WSDL – Web Service
Description Language
Web Service
Program
Stubs
Ties
 beschreibt WebServiceSchnittstelle mit XML
 Erlaubt Generierung der Stubs
für unterschiedliche Plattformen
wsimport
WSDL
JAX-WS
Runtime
Web Container
SOAP
 Remote Procedure Calls mit XMLSerialisierung
Client
Program
Web Service
Program
Stubs
Ties
JAX-WS
Runtime
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
SOAP
JAX-WS
Runtime
7
Web-Services im Vergleich
Java RMI
.NET Remoting
CORBA
Web-Services
Programmiersprache
Java
.NET Sprachen
(C#, VB.NET, ..)
unabhängig
unabhängig
Schnittstellendefinition
Java Interfaces
.NET Interfaces
CORBA IDL
WSDL (XMLbasiert)
Datenstrukturen
Java Objekte
.NET Objekte
IDL-spezifizierte
Objekte
XML-Daten
Übertragungsprotokoll
RMI-IIOP
binär oder SOAP
GIOP/IIOP
HTTP, HTTPS,
SMTP, FTP
Verpackung
Java ObjektSerialisierung
.NET ObjektSerialisierung
ORB/CDR
SOAP
Infrastruktur
Java RMIInfrastruktur
.NET RemotingInfrastruktur
ORBs
Web-, Mail-, FTPServer
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
8
Vor- und Nachteile
Vorteile
 unabhängig von Programmiersprache, Laufzeitumgebung und
Betriebssystem
 baut auf bestehender Internet-Infrastruktur auf
 standardisiert
Nachteile
 Performance (XML)
 keine wirklichen Objektkommunikation wie bei RMI
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
9
Web Services
Einführung
Web-Services in Java
JAXB
SOAP und WSDL
Zusammenfassung
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
10
Web Service Implementierung in Java (1 / 4)
Package javax.jws
Implementierung einer Service-Klasse
package personservice;
...
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public class PersonManager {
private Map<Long, Person> persons;
public PersonManager() { … }
Annotation der Klasse als WebService
Parameterloser Konstruktor
Annotation der Methoden als WebMethod
@WebMethod
public String getPersonName(long ssn) {
return persons.get(ssn).getName();
}
…
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
11
Web Service Implementierung in Java (2 / 4)
Generierung der Stub-Klassen mit wsgen
Verzeichnis mit class-Files
 Aus den class-Files werden Stub-Klassen für die Serialisierung der
Requests und Responses in XML erzeugt
JAXB Serialisierung!
Unterverzeichnis .jaxws
package personservice.jaxws;
…
@XmlRootElement(name = "getPersonName",
namespace = "http://personservice/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getPersonName",
namespace = "http://personservice/")
public class GetPersonName {
package personservice.jaxws;
...
@XmlRootElement(name = "getPersonNameResponse",
namespace = "http://personservice/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getPersonNameResponse",
namespace = "http://personservice/")
public class GetPersonNameResponse {
@XmlElement(name = "arg0", namespace = "")
private long arg0;
@XmlElement(name = "return", namespace = "")
private String _return;
public long getArg0() {
return this.arg0;
}
public String getReturn() {
return this._return;
}
public void setArg0(long arg0) {
this.arg0 = arg0;
}
public void setReturn(String _return) {
this._return = _return;
}
}
Pratikum SWE 2
}
© Institut für Systemsoftware, Johannes Kepler Universität Linz
12
Web Service Implementierung in Java (3 / 4)
Starten des Servers und Publikation des Web Service mit Endpoint
package personservice;
import javax.xml.ws.Endpoint;
public class PersonSerciceStart {
public static void main(String[] args) {
Endpoint ep =
Endpoint.publish("http://localhost:8080/WebServices/personservice", new PersonManager());
...
ep.stop();
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
13
Web Service Implementierung in Java (4 / 4)
Web Service muss laufen!

Abrufen der WSDL Interface Beschreibung

Abrufen der XML-Schemabeschreibungen
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
14
Web Service Client
Implementierung eines Clients:
Generierung der Stub-Klassen für Client aus WSDL

WSDL vom Web Server
Requests und Responses
Marshalling Datenobjekte
Object Factory
Interface für Web Service
Factory for Web Service
Implementierung des Clients unter Verwendung der generierten Stub-Klassen

package personservice.client;
import personservice.server.*;
public class PersonServiceClient {
public static void main(String[] args) {
PersonManagerService service = new PersonManagerService();
PersonManager port = service.getPersonManagerPort();
Erzeugen des Web Service
Schnittstelle zu Web Service
String franzName = port.getPersonName(8512031111L);
System.out.println(franzName);
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
15
Web Services
Einführung
Web-Services in Java
JAXB
SOAP und WSDL
Zusammenfassung
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
16
Java Architecture for XML Binding (JAXB 2.0)
Daten werden bei Java Web Services mit JAXB kodiert!
Bindet Objektzustände an XMLDokumente
Mit Annotationen
 Abbildung durch Schema oder
Annotationen festlegbar
 Klassen aus Schema oder
Schema aus Klassen generieren
 Automatisches Serialisieren ganzer
Objektbäume
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
17
JAXB 2.0 – API: wichtige Annotationen
Namespaces
 javax.xml.bind
 javax.xml.bind.annotation
Annotationen:
 @XmlRootElement
 @XmlElement
 Klassen, Enums
 Properties, Felder
 Abbildung auf XML-Elemente
 Abbildung auf XML-Elemente
 @XmlAttribute
 @XmlType
 Klassen, Enums
 Properties, Felder
 Definition von XML-Complex Types
 Abbilding auf XML-Attribute
 @XmlEnum und @XmlEnumValue
 @XmlAdapter
 Enums
 Properties, Felder
 Abbilding auf String-Werte
 Anpassung der Abbildung bestimmter
Properties
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
18
JAXB – Java Architecture for XML Binding
Kodierung von wichtigen Java-Datentypen
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
19
Annotierung von JavaBeans
JavaBean = Klasse nach bestimmtem Schema
• Properties
• parameterloser Konstruktor
XML-Serialisierung von JavaBeans

Annotation der Klasse mit @XmlType

Annotation der Getter-Methoden oder Felder mit


@XmlElement: Serialisierung als XMl-Element
@XmlAttribute : Serialisierung als XML-Attribut
@WebService
public class PersonManager {
...
JAXB-Binding von
Person notwendig
@XmlType
public class Person {
private long ssn;
private String name; Parameterloser
Konstruktor
public Person() {
}
@WebMethod
public Person getPerson(long ssn) {
return persons.get(ssn);
}
@XmlAttribute
public long getSSN() {
return ssn;
}
@WebMethod
public void addPerson(Person p) {
persons.put(p.getSSN(), p);
}
@XmlElement
public String getName() {
return name;
}
}
}
Pratikum SWE 2
Properties
© Institut für Systemsoftware, Johannes Kepler Universität Linz
20
Xml-Serialisierung: Enumerationen
@XmlType
einfache Serialisierung von Enums
@XmlEnum
Serialisierung als Strings
@XmlEnumValue
Bestimmung des Strings
@XmlType
public class Person {
@XmlType
@XmlEnum
public enum Sex {
private Sex sex;
...
@XmlAttribute
public Sex getSex() {
return sex;
}
}
Pratikum SWE 2
optional
@XmlEnumValue("Male")
MALE,
@XmlEnumValue("Female")
FEMALE;
}
© Institut für Systemsoftware, Johannes Kepler Universität Linz
21
Xml-Serialisierung: Listen
@XmlElement
@XmlType
public class Person {
...
private Sex sex;
@XmlElement
public List<Person> getChildren() {
return Collections.unmodifiableList(children);
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
22
Xml-Serialisierung: XmlAdapter (1 / 3)
Bestimmte Java-Typen lassen sich schlecht abbilden
Z.B. Arrays
@XmlType
public class Person {
...
private char[][] logo;
@XmlElement
public char[][] getLogo() {
return logo;
}
}
Client-Side Stub
@XmlType(name = "person", ... )
public class Person {
...
protected List<UnsignedShortArray> logo;
public List<UnsignedShortArray> getLogo() {
...
return this.logo;
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
23
Xml-Serialisierung: XmlAdapter (2 / 3)
XML-Serialisierung über Umweg von XmlAdapter
package javax.xml.bind.annotation.adapters;
public abstract class XmlAdapter<ValueType,BoundType> {
protected XmlAdapter() { }
public abstract BoundType unmarshal(ValueType v) throws Exception;
public abstract ValueType marshal(BoundType v) throws Exception;
}
Annotierung mit @XmlJavaTypeAdapter
@XmlType
public class Person {
...
private char[][] logo;
@XmlJavaTypeAdapter(LogoAdapter.class)
public char[][] getLogo() {
return logo;
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
24
Xml-Serialisierung: XmlAdapter (3 / 3)
marschall char[][] -> String und
unmarshall String -> char[][]
Client-Side Stub
arbeitet mit Strings
package personservice;
import javax.xml.bind.annotation.adapters.XmlAdapter;
@XmlType(name = "person", ... )
public class Person {
...
protected String logo;
public class LogoAdapter extends XmlAdapter<String, char[][]> {
@Override
public String marshal(char[][] logo) throws Exception {
StringBuilder b = new StringBuilder();
for (char[] line : logo) {
for (char c: line) {
b.append(c);
}
b.append("\n");
}
return b.toString();
}
@Override
public char[][] unmarshal(String logoString) throws Exception {
String[] lines = logoString.split("\n");
char[][] logo = new char[lines.length][];
for (int i = 0; i < lines.length; i++) {
logo[i] = new char[lines[i].length()];
for (int j = 0; j < lines[i].length(); j++) {
logo[i][j] = lines[i].charAt(j);
}
}
return logo;
}
public String getLogo() {
return this.logo;
}
}
{ {'l'‚ 'o'},
{'g'‚ 'o'} }
"lo\ngo"
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
25
Annotation der Parameter: @WebParam
Parameternamen (für Client-Side)
@WebService
Ansonsten Parametername arg0
public class PersonManager {
...
auf Client-Side
@WebMethod
public Person getPerson(@WebParam(name = "ssn") long ssn) {
...
OUT und INOUT Parameter
 Mit Verwendung von Holder<T>
@WebService
public class PersonManager {
...
@WebMethod
public boolean selectPerson(
@WebParam(mode = WebParam.Mode.INOUT, name = "selected") Holder<Person> holder
) {
Person p = …
holder.value = p;
return true;
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
26
Web Methods mit Exceptions (1/2)
 Web Methods können Exceptions werfen
 werden in SOAP kodiert
 und können am Client behandelt werden

am Client eigene Exception-Klasse <XYException>_Exception
Beispiel: getPerson mit PersonException
 WebMethod-Implementierung
public class PersonException extends Exception {
private long ssn;
public PersonExcpetion(String message, long ssn) {
super(message);
this.ssn = ssn;
}
public long getSsn() { return ssn; }
}
@WebService
public class PersonManager {
...
@WebMethod
public Person getPerson(@WebParam(name = "ssn") long ssn) throws PersonExcpetion {
Person p = persons.get(ssn);
if (p == null) {
throw new PersonException("No person with ssn ", ssn);
}
return p;
}
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
27
Web Methods mit Exceptions (2/2)
 Für Exception-Klasse wird zur Kodierung der Daten Bean-Klasse erzeugt
package personservice.jaxws;
@XmlRootElement(name = "PersonExcpetion", namespace = "http://personservice/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PersonExcpetion", namespace = "http://personservice/")
public class PersonExcpetionBean {
private String message; private long ssn;
public String getMessage() { return this.message; }
public long getSsn() { return ssn; }
}
 Für Client wird eine eigene Exception-Klasse PersonException_Exception
erzeugt, die die Daten der ursprünglichen Exception kapselt
@WebFault(name = "PersonExcpetion", targetNamespace = "http://personservice/")
public class PersonExcpetion_Exception extends Exception {
private PersonExcpetion faultInfo;
public PersonExcpetion_Exception(String message, PersonExcpetion faultInfo) {…}
public PersonExcpetion getFaultInfo() { return faultInfo; }
}
Zugriff auf Daten der Exception
 Anwendung am Client
try {
Person p = port.getPerson(123401012000L);
} catch (PersonExcpetion_Exception e) {
… e.getFaultInfo.getMessage() … e.getFaultInfo().getSsn();
}
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
Zugriff auf Eigenschaften der
ursprünglichen Exception
28
Web Services
Einführung
Web-Services in Java
JAXB
SOAP und WSDL
Zusammenfassung
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
32
XML-Struktur (vereinfacht, SOAP 1.2)
<?xml version="1.0" ?>
<soap:Envelope xmlns:soap=“http://www.w3c.org.2003/05/soap-envelope">
<soap:Header> <!-- (optional and extendable) -->
<m:my xmlns:m="anURI"
soap:mustUnderstand=“true" soap:role=“uri2" />
...
</soap:Header>
<soap:Body>
Umschlag (<Envelope>)
Briefkopf (<Header>)
mit beliebigen Metainformationen
Brief (<Body>)
data (depends on format and encoding)
mit beliebigen XML-Daten
<soap:Fault>
<soap:Code>...who is responsible?... </Code>
<soap:Reason>...textual description...</soap:Reason>
<soap:Detail>...more error details...</soap:Detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
Fehlerbeschreibungen
34
Grundstruktur von WSDL 1.1
<definitions>
<types>
</types>
<message>
<part>
</part>
</message>
<portType>
<operation>
<input>
<output>
</operation>
</portType>
<binding>
<operation>
</binding>
<service>
<port>
</service>
</definitions>
Pratikum SWE 2
WSDL-Beschreibung eines Web-Services
Typen beschrieben in <xsd:schema>
einzelne Nachrichten
Teile der Nachricht
Interface-Beschreibung
Operationen eines Interfaces
Input-Nachricht
Output-Nachricht
abstrakter
Teil
Binden von Interfaces an Protokolle + Kodierung
Beschreibung der Anbindung für jede Operation
Servicebeschreibung
URI und Anbindung für Port
© Institut für Systemsoftware, Johannes Kepler Universität Linz
konkreter
Teil
38
Beispiel: WSDL for PersonManager (1 / 3)
WSDL Beschreibung des PersonManager abgerufen vom Web-Server
http://localhost:8080/WebServices/personservice?wsdl
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsp="http://www.w3.org/ns/ws-policy"
xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://personservice/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://personservice/"
name="PersonManagerService">
<types>
<xsd:schema>
<xsd:import amespace="http://personservice/"schemaLocation="http://localhost:8080/WebServices/personservice?xsd=1"/>
</xsd:schema>
</types>
<message name="getPersonName">
<part name="parameters" element="tns:getPersonName"/>
</message>
<message name="getPersonNameResponse">
<part name="parameters" element="tns:getPersonNameResponse"/>
</message>
<message name="addPerson">
<part name="parameters" element="tns:addPerson"/>
</message>
<message name="addPersonResponse">
…
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
39
Beispiel: WSDL for PersonManager (2 / 3)
...
<portType name="PersonManager">
<operation name="getPersonName">
<input wsam:Action="http://personservice/PersonManager/getPersonNameRequest" message="tns:getPersonName"/>
<output wsam:Action="http://personservice/PersonManager/getPersonNameResponse" message="tns:getPersonNameResponse"/>
</operation>
<operation name="getNumberPersons">
<input wsam:Action="http://personservice/PersonManager/getNumberPersonsRequest" message="tns:getNumberPersons"/>
<output wsam:Action="http://personservice/PersonManager/getNumberPersonsResponse" message="tns:getNumberPersonsResponse"
...
</portType>
<binding name="PersonManagerPortBinding" type="tns:PersonManager">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getPersonName">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="addPerson">
<input wsam:Action="http://personservice/PersonManager/addPersonRequest" message="tns:addPerson"/>
<output wsam:Action="http://personservice/PersonManager/addPersonResponse" message="tns:addPersonResponse"/>
</operation>
...
</binding>
<service name="PersonManagerService">
<port name="PersonManagerPort" binding="tns:PersonManagerPortBinding">
<soap:address location="http://localhost:8080/WebServices/personservice"/>
</port>
</service>
</definitions>
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
40
Beispiel: WSDL for PersonManager (3 / 3)
Beschreibung der XML-Typen abgerufen vom Web-Server mit
http://localhost:8080/WebServices/personservice?xsd=1
<xs:schema xmlns:tns="http://personservice/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0"
targetNamespace="http://personservice/">
<xs:element name="addPerson" type="tns:addPerson"/>
<xs:element name="addPersonResponse" type="tns:addPersonResponse"/>
<xs:element name="getPerson" type="tns:getPerson"/>
<xs:element name="getPersonResponse" type="tns:getPersonResponse"/>
<xs:element name="getPersonName" type="tns:getPersonName"/>
<xs:element name="getPersonNameResponse" type="tns:getPersonNameResponse"/>
<xs:complexType name="person">
<xs:sequence>
<xs:element name="age" type="xs:int"/>
<xs:element name="children" type="tns:person" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="hobbies" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="logo" type="xs:string" minOccurs="0"/>
<xs:element name="name" type="xs:string" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="ssn" type="xs:long" use="required"/>
<xs:attribute name="sex" type="tns:sex"/>
</xs:complexType>
<xs:complexType name="getPersonName">
<xs:sequence>
<xs:element name="arg0" type="xs:long"/>
</xs:sequence>
</xs:complexType>
...
</xs:schema>
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
41
41
Annotationen Zusammenfassung
WebService
String endpointInterface
The complete name of the service endpoint interface defining the service's
abstract Web Service contract.
String name
The name of the Web Service.
String portName
The port name of the Web Service.
String serviceName
The service name of the Web Service.
String targetNamespace
If the @WebService.targetNamespace annotation is on a service endpoint
interface, the targetNamespace is used for the namespace for the
wsdl:portType (and associated XML elements).
String wsdlLocation
The location of a pre-defined WSDL describing the service.
WebMethod
String action
The action for this operation.
Boolean exclude
Marks a method to NOT be exposed as a web method.
String operationName
Name of the wsdl:operation matching this method
WebParam
boolean header
If true, the parameter is pulled from a message header rather then the
message body.
WebParam.Mode mode
The direction in which the parameter is flowing (One of IN, OUT, or INOUT).
String name
Name of the parameter.
String partName
The name of the wsdl:part representing this parameter.
String targetNamespace
The XML namespace for the parameter.
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
42
Annotationen Zusammenfassung
XmlType
Class factoryClass
Class containing a no-arg factory method for creating an instance of this
class.
String factoryMethod
Name of a no-arg factory method in the class specified in factoryClass
factoryClass().
String name
Name of the XML Schema type which the class is mapped.
String namespace
Name of the target namespace of the XML Schema type.
String[] propOrder
Specifies the order for XML Schema elements when class is mapped to a XML
Schema complex type
XmlElement
String defaultValue
Default value of this element.
String name
Name of the XML Schema element.
String namespace
XML target namespace of the XML Schema element.
boolean nillable
Customize the element declaration to be nillable.
boolean required
Customize the element declaration to be required.
Class type
The Java class being referenced.
XmlAttribute
String name
Name of the XML Schema attribute.
String namespace
Specifies the XML target namespace of the XML Schema attribute.
boolean required
Specifies if the XML Schema attribute is optional or required.
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
43
Web Services
Einführung
Web-Services in Java
JAXB
SOAP und WSDL
Zusammenfassung
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
44
Zusammenfassung
Web-Services sind eine Middleware-Technologie
auf der Basis von XML und Internet-Protokollen
unabhängig von Programmiersprache und Laufzeitumgebung
für die Integration heterogener, verteilter Systeme
Java unterstützt Web-Service-Technologie
 javax.ws für Entwicklung von Web-Services mit Verwendung von Annotationen
 javax.xml.bind für JAXB-Datenbindung
 wsgen für Generierung von Ties (Brückencode)
 wsimport für Generierung von Stubs
 Entwicklung von Web-Service-Clients
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
45
Literatur
Horstmann, Cornell, Core Java 2, Volume II . Advance Features,Sun
Microsystems, 2008: Chapter 10
The Java EE 6 Tutorial, Oracle Inc., 2012,
http://docs.oracle.com/javaee/6/tutorial/doc/
The Java Web Services Tutorial 2.0, Oracle Inc., 2006,
http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/2.0/tutorial/doc/
Pratikum SWE 2
© Institut für Systemsoftware, Johannes Kepler Universität Linz
46
Herunterladen