JAX-RPC (Web Services) ΕΠΛ 425: Τεχνολογίες ιαδικτύου Μιχάλης Έλληνας
ΕΠΛ 425: Τεχνολογίες ιαδικτύου (εν συντοµία ) Στόχος: η παρουσίαση τεχνολογιών, λογισµικών πακέτων, πρωτοκόλλων, συµβάσεων και πρακτικών µε διαδικτυακές εφαρµογές. Προβλήµατα που παρουσιάστηκαν Θέµατα που καλύφθηκαν: Χρήση της Java για: Αρχιτεκτονική Client Server Servlets Multithreading XML (SAX, DOM) JAX-RPC υναµικό περιεχόµενο (PHP, servlets, ) The Apache server Macromedia Director Dreamweaver Web Accessibility Initiative ( ) ΕΠΛ 425: Τεχνολογίες ιαδικτύου 2
JAX-RPC: εισαγωγικά Java API for XML-based RPC Technology for building web services A remote procedure call is represented by an XMLbased protocol such as SOAP. The JAX-RPC runtime system converts the API calls and responses to and from SOAP messages. Advantages Platform independence Not restrictive (adherence to W3C specs) Protocols of relevance: SOAP (Simple Object Access Protocol) WSDL (Web Service Description Language) ΕΠΛ 425: Τεχνολογίες ιαδικτύου 3
JAX-RPC: εισαγωγικά Service Endpoint Interface (SEI) A Java interface that declares the methods that a client can invoke on the service. Steps for creating the web service: 1. Code the SEI and implementation class and interface configuration file. 2. Compile the SEI and implementation class. 3. Generate the files required to deploy the service. 4. Package the files into a WAR file. 5. Deploy the WAR file. Steps for creating the client: 1. Code the client class and WSDL configuration file. 2. Generate and compile the stub files. 3. Compile the client class. 4. Run the client. ΕΠΛ 425: Τεχνολογίες ιαδικτύου 4
JAX-RPC: Web Service Client communication ΕΠΛ 425: Τεχνολογίες ιαδικτύου 5
Types Supported by JAX-RPC J2SE SDK Classes java.lang.boolean java.lang.byte java.lang.double java.lang.float java.lang.integer java.lang.long java.lang.short java.lang.string java.math.bigdecimal java.math.biginteger java.net.uri java.util.calendar java.util.date Primitives boolean byte double float int long short (Multidimensional) Arrays Value Types JavaBeans Components ΕΠΛ 425: Τεχνολογίες ιαδικτύου 6
Service endpoint interface and implementation class import java.rmi.remote; import java.rmi.remoteexception; public interface ExampleIF extends Remote { public <type> function_x(<arguments>) throws RemoteException; } public class ExampleImpl implements ExampleIF { public <type> function_x(<arguments>) { } } ΕΠΛ 425: Τεχνολογίες ιαδικτύου 7
Static Stub Client import javax.xml.rpc.stub; public static void main(string[] args) { try { Stub stub = createproxy(); stub._setproperty(javax.xml.rpc.stub.endpoint_address_property, <Endpoint_Address>); ExampleIF example = (ExampleIF) stub; } example.function_x(<arguments>); } catch (Exception ex) { ex.printstacktrace(); } ΕΠΛ 425: Τεχνολογίες ιαδικτύου 8
Web Service Clients Dynamic proxy The class (dynamic proxy) is created during runtime Dynamic Invocation Interface (DII) Remote procedure invocation even if the signature of the remote procedure or the name of the service is unknown until runtime Application client Invocation of the JNDI (Java Naming and Directory Interface) lookup method ΕΠΛ 425: Τεχνολογίες ιαδικτύου 9
Related concepts SAAJ: The SOAP with Attachments API for Java A low-level API on which JAX-RPC depends SOAP: Simple Object Access Protocol SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment. It uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged over a variety of underlying protocols. The framework has been designed to be independent of any particular programming model and other implementation specific semantics. Two major design goals for SOAP are simplicity and extensibility (see XMLP Requirements [XMLP Requirements]). SOAP attempts to meet these goals by omitting, from the messaging framework, features that are often found in distributed systems. Such features include but are not limited to "reliability", "security", "correlation", "routing", and "Message Exchange Patterns. (W3C XML Protocol Working Group) WSDL: Web Service Description Language WSDL provides a model and an XML format for describing Web services. WSDL 2.0 enables one to separate the description of the abstract functionality offered by a service from concrete details of a service description such as how and where that functionality is offered (W3C WSDL) Web Services Web Services provide a standard means of interoperating between different software applications, running on a variety of platforms and/or frameworks. Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions thanks to the use of XML. They can be combined in a loosely coupled way in order to achieve complex operations. Programs providing simple services can interact with each other in order to deliver sophisticated added-value services (W3C Web Services Activity Statement) ΕΠΛ 425: Τεχνολογίες ιαδικτύου 10
Αναφορές Σύνδεσµοι The J2EE 1.4 Tutorial JAX-RPC home: http://java.sun.com/webservices/jaxrpc/ JAX-RPC Specifications: http://java.sun.com/xml/downloads/jaxrpc.html Web Wide Web Consortium (W3C) Web Services Activity: http://www.w3.org/2002/ws/ SOAP: http://www.w3.org/2000/xp/group/ WSDL: http://www.w3.org/tr/wsdl20/ ΕΠΛ 425: Τεχνολογίες ιαδικτύου 11