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.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Java Web Services.
31242/32549 Advanced Internet Programming Advanced Java Programming
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Java Web Services Developer Pack v1.3 Zhongnan Shen 12/04/2003.
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.
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.
Web Services with Apache CXF Part 2: JAXB and WSDL to Java Robert Thornton.
1 Lecture 21 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 Lecture 22 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.
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 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.
+ A Short Java RMI Tutorial Usman Saleem
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.
XML and Web Services (II/2546)
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.
Presentation: Advanced AXIS: Deployment Descriptors and Advanced Types.
.NET Mobile Application Development XML Web Services.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
(C) 2003 University of ManchesterCS31010 Lecture 14: CORBA.
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.
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.
Distributed Web Systems Distributed Objects and Remote Method Invocation Lecturer Department University.
Java Distributed Computing
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
WEB SERVICES.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Writing simple Java Web Services using Eclipse
Lecture 7 Examples for Web Service
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Remote Method Invocation
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
Introduction to Web Services
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Introduction to Web Services
Understanding Web Services based on dev. java
Quiz Points 4 Rules Raise your hand if you know the question
WebServices Using JAX-RPC
Introduction to Web Services
Distributed System using Web Services
Chapter 42 Web Services.
Java Remote Method Invocation
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Distributed System using Web Services
Presentation transcript:

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.

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.

Web Services-JAX-RPC

Web Services-JAX-RPC 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.

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.

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.

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";

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

EE5 and Web Services-JAX-WS Here is another example with more annotations: @WebService(name=”CreditRatingService”, targetNamespace=”http://example.org”) public class CreditRating { @WebMethod(operationName=”getCreditScore”) public Score getCredit( @WebParam(name=”customer”) Customer c { // ... implementation code ... }

EE5 and Web Services-JAX-WS 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 the @WebService annotation in the implementation class. You must then provide an interface that defines the public methods made available in the endpoint implementation class.

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.

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.

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

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. the @WebService annotation has attributes:

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

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. @WebServiceRef uses the wsdlLocation element to specify the URI of the deployed service’s WSDL file. @WebServiceRef(wsdlLocation="http://localhost:8080/helloservice/hello?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);

EE5 and Web Services-JAX-WS public class HelloClient { @WebServiceRef(wsdlLocation="http://localhost:8080/ helloservice/hello?wsdl") static HelloService service; ……………………………………………………… Hello port = service.getHelloPort(); String response = port.sayHello(name); System.out.println(response); …………………………………………………………….

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.

EE5 and Web Services-JAXB Architecture.

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.

EE5 and Web Services-JAXB Architecture. XML Schema Type Java Data Type xsd:string java.lang.String xsd:integer java.math.BigInteger xsd:int int xsd.long long xsd:short short xsd:decimal java.math.BigDecimal xsd:float float

EE5 and Web Services-JAXB Architecture

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.

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.

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: http://www.netbeans.org/kb/docs/websvc/jax-ws.html