1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Java Web Services.
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
RPC Robert Grimm New York University Remote Procedure Calls.
JAXB Java Architecture for XML Binding Andy Fanton Khalid AlBayat.
Webservices using JAXB and JAX-WS Lalit Bhatt SpiderLogic
6/2/2015Page 1 SOA Development and Deployment B. Ramamurthy.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 42 Web Services.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
DISTRIBUTED FILE SYSTEM USING RMI
Lecture 10: Web Services. Outline Overview of Web Services Create a Web Service with Sun J2EE (JAX-RPC)
Comparison of the RMI and the socket APIs
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Java RMI, JAX-RPC and JWSDP
JAX-RPC The Java API for XML Remote Procedure Calls Notes from The J2EE Tutorial 1.4 From Sun Microsystems.
Intro to Programming Java Web Services using the Java TM API for XMLWeb Services (JAX-WS) Bill Champlin UCCS / CS526 Spring ‘09.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
1 Lecture 21 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
CS 157B: Database Management Systems II February 27 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
Notes of J2EE Tutorial Matt Tsai. 2 Outline Chapter 1: Overview Chapter 1: Overview Chapter 2: Understanding XML Chapter 2: Understanding XML Chapter.
SSC2: Web Services. Web Services Web Services offer interoperability using the web Web Services provide information on the operations they can perform.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Grid Computing, B. Wilkinson, 20043b.1 Web Services Part II.
1 Core Web Services Standards. 2 (Simplified) Web Service Architecture Registry 1. Service Registers PUBLISH 3. Client calls Service BIND 2. Client Request.
COP 4991 Component Based Software Development Lecture #4 Java Web Services Onyeka Ezenwoye.
1 HRS2422 Web Services JAX-WS and SOAP Introduction  Web service – A software component stored on one computer that can be accessed via method.
1 Stateful Session Beans Stateless Session Beans Michael Brockway Sajjad Shami Northumbria University School of Computing, Engineering & Information Sciences.
Web servisu izstrāde JAX-WS. Ievads JAX-WS = Java API for XML Web Services JAX-WS ir fundamentāla Web servisu izstrādes tehnoloģija Java EE 5 un Java.
J2EE Structure & Definitions Catie Welsh CSE 432
+ A Short Java RMI Tutorial Usman Saleem
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
DEVELOPING WEB SERVICES WITH JAVA WEB SERVICES. CONTENTS JAXP JAX-RPC JAXR SAAJ JAXB Steps to create Web Services with Java Object Class using NetBeans.
Web Services with Apache CXF Part 2: JAXB and WSDL to Java Robert Thornton.
Distributed Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE CLIENT.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
XML and Web Services (II/2546)
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
ODS – Introduction to Web Services and BPEL Vakgroep Informatietechnologie Web Services & BPEL Design of Distributed Software.
Java Web Services CSCI 4300 Diagrams from the Sun Java Web Services Tutorial,
WSDL : Web Service Definition Language Dr. Yuhong Yan NRC-IIT-Fredericton Internet logic.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
.NET Mobile Application Development XML Web Services.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
(C) 2003 University of ManchesterCS31010 Lecture 14: CORBA.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
WP3 Implementing R-GMA grid services in GT3 Abdeslem Djaoui & WP3 Grid Services Task Force 7 th EU Datagrid meeting 26/09/2003
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
SOAP, Web Service, WSDL Week 14 Web site:
The Java API for XML-Based Web Services. A Web Service example in Java SOAP-awareServlet (e.g. Apache Axis2) SOAP-awareServlet Any class processing the.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Web Services Orca Knowledge Center – Web Service key concepts.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Chapter 5 Remote Procedure Call
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model.
Understanding Web Services based on dev. java
WebServices Using JAX-RPC
Introduction to Web Services
Distributed System using Web Services
Chapter 42 Web Services.
Distributed System using Web Services
Presentation transcript:

1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES

Topics Web Services- APIs used in EE5 – JAX-RPC (before EE5) – JAX-WS – JAXB 2

Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model. A Web service endpoint is deployed on either the Web container or EJB container based on the corresponding component model. These endpoints are described using a WSDL document. This WSDL document can be published in public or private registry, though this is not required. A client uses this WSDL document and invokes the Web service endpoint. A JAX-RPC client can use stubs-based, dynamic proxy or dynamic invocation interface (DII) programming models to invoke a heterogeneous Web service endpoint. 3

Web Services-JAX-RPC RPC stands for Remote Procedure Call. – A protocol used by Microsoft in their systems. – RMI (and its offsprings) is similar to RPC. JAX-RPC allows the communication of a web service client with a web component/ejb session bean so that the web service can be invoked via the business rules model. 4

Web Services-JAX-RPC 5

It is assumed that the client is aware of the Web service and the remote procedure that it can execute on the Web service. This is what happens: – The client calls the method on the stub that represents the remote procedure. – The stub executes the necessary routines on the JAX-RPC runtime system. – The runtime system converts this method call into a SOAP message and transmits the message to the server as an HTTP request. – The server, upon receipt of the SOAP message, invokes the methods on the JAX-RPC runtime. The JAX-RPC runtime converts the SOAP request into a method call. – The JAX-RPC runtime then calls the method on the tie object. – Finally, the tie object calls the method on the implementation of the Web service. – The response to the RPC call is sent in a SOAP response message as an HTTP response. 6

Web Services-JAX-RPC The Web service is represented by two files: the service definition interface, and the corresponding implementation class. The service definition interface and the implementation class are collectively known as the service endpoint. 7

EE5 and Web Services-JAX-WS Java EE5 provides annotations for Web Services. JAX-WS 2.0 is the new API for web services in the Java EE 5 platform and it is a successor to JAX-RPC. 8

EE5 and Web Services-JAX-WS Example comparing the approach between JAX-RPC and JAX-WS 2.0 JAX-RPC Web Service: public interface HelloService extends Remote { public String sayHello(String name) throws RemoteException; } public class HelloServiceBean implements SessionBean { public String sayHello(String name) { return "Hello "+ name + " from HelloServiceBean"; } 9

EE5 and Web Services-JAX-WS Example using JAX-WS public class HelloServiceBean { public String sayHello(String name) { return "Hello "+ name + " from HelloServiceBean"; } Notice that: – No need for an interface! – annotation defines the class as a web service end point. 10

EE5 and Web Services-JAX-WS Here is another example with more targetNamespace=” public class CreditRating public Score Customer c { //... implementation code... } 11

EE5 and Web Services-JAX-WS 12 Our diagram is now revised to show that the JAX-WS runtime environment is used instead of JAX-RPC. Notice that the service can also be an ejb.

EE5 and Web Services-JAX-WS You may specify an explicit interface by adding the endpointInterface element to annotation in the implementation class. You must then provide an interface that defines the public methods made available in the endpoint implementation class. 13

EE5 and Web Services-JAX-WS The wsgen tool and the Application Server provide the Application Server’s implementation of JAX-WS. – wsgen generates all articrafts (files) needed for the implementation of the web service. 14

EE5 and Web Services-JAX-WS Building a Web Service With Java WSDP 2.0 – Write an endpoint implementation class. – Compile the endpoint implementation class. – Generate portable artifacts required for web service by using wsgen tool. – Package the web service as a WAR file and deploy it. – Code the client class. – Use wsimport tool to generate and compile the web service artifacts needed to connect to the service. – Compile the client class. – Run the client. 15

EE5 and Web Services-JAX-WS Suppose our end point service class is: package helloservice.endpoint; import public class Hello { private String message = new String("Hello, "); public void Hello() {} public String sayHello(String name) { return message + name + "."; } 16

EE5 and Web Services-JAX-WS You can build, package, and deploy the helloservice application using either NetBeans IDE or ant. Notice that the WSDL file is generated automaticaly (as well as the descriptor files needed). Also, notice that XML is totally hidden from the developer. Keep in mind that annotations come with attributes: i.e. annotation has attributes: 17

EE5 and Web Services-JAX-WS – endpointInterface – name – portName – serviceName – targetNamespace – wsdlLocation 18

EE5 and Web Services-JAX-WS Coding the Client When invoking the remote methods on the port, the client performs these steps: – Uses the javax.xml.ws.WebServiceRef annotation to declare a reference to a web service. uses the wsdlLocation element to specify the URI of the deployed service’s WSDL file. ello?wsdl") static HelloService service; – Retrieves a proxy to the service, also known as a port, by invoking getHelloPort on the service. – Hello port = service.getHelloPort();The port implements the SEI defined by the service. – Invokes the port’s sayHello method, passing to the service a name. – String response = port.sayHello(name); 19

EE5 and Web Services-JAX-WS public class HelloClient helloservice/hello?wsdl") static HelloService service; ……………………………………………………… Hello port = service.getHelloPort(); String response = port.sayHello(name); System.out.println(response); ……………………………………………………………. 20

EE5 and Web Services-JAXB JAX-WS delegates the mapping of the Java language data types to JAXB API. – JAXB stands for Java Architecture for XML Binding. – JAXB converts XML schemas to Java Content trees (see example in previous lecture of a content tree) and vice versa. 21

EE5 and Web Services-JAXB Architecture. 22

EE5 and Web Services-JAXB Architecture. Basically JAXB is the translator of XML schemas (and data types) to Java and vice versa. – Since the WSDL describes the XML schema there is a need to translate that schema to Java. – It is the job of JAXB to do just that. 23

EE5 and Web Services-JAXB Architecture. XML Schema Type Java Data Type xsd:stringjava.lang.String xsd:integerjava.math.BigInteger xsd:intint xsd.longlong xsd:shortshort xsd:decimaljava.math.BigDecimal xsd:floatfloat 24

EE5 and Web Services-JAXB Architecture 25

EE5 and Web Services-JAXB Architecture Generate classes: An XML schema is used as input to the JAXB binding compiler to generate JAXB classes based on that schema. Compile classes: All of the generated classes, source files, and application code must be compiled. Unmarshal: XML documents written according to the constraints in the source schema are unmarshalled by the JAXB binding framework. Note that JAXB also supports unmarshalling XML data from sources other than files/documents, such as DOM nodes, string buffers, SAX Sources, and so forth. Generate content tree: The unmarshalling process generates a content tree of data objects instantiated from the generated JAXB classes; this content tree represents the structure and content of the source XML documents. 26

EE5 and Web Services-JAXB Architecture Validate (optional): The unmarshalling process optionally involves validation of the source XML documents before generating the content tree. Note that if you modify the content tree in step below, you can also use the JAXB Validate operation to validate the changes before marshalling the content back to an XML document. Process content: The client application can modify the XML data represented by the Java content tree by means of interfaces generated by the binding compiler. Marshal: The processed content tree is marshalled out to one or more XML output documents. The content may be validated before marshalling. 27

EE5 and Web Services-NetBeans support. NetBeans 6.5 provides support for web services using JAX-WS and JAXB. For more information on how to use NetBeans to develop a web service by utilizing JAX-WS and JAXB see the NetBeans tutorial at: ws.html 28

Study Guide EE5 Tutorial text chapter 15. EE5 Tutorial text chapter 16 NetBeans tutorial online. EE5 Tutorial chapters 11,12 29