EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL JAX-RPC 17 th October 2004 www.eu-egee.org.

Slides:



Advertisements
Similar presentations
Java Web Services.
Advertisements

Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
A1.1 Assignment 1 “Deploying a Simple Web Service”
Copyright © 2001 Qusay H. Mahmoud RMI – Remote Method Invocation Introduction What is RMI? RMI System Architecture How does RMI work? Distributed Garbage.
EGEE is a project funded by the European Union under contract IST WSDL Web Service Description Language 3 – 4 June
Enabling Grids for E-sciencE ISSGC 05 Web Service Tools NeSC Training Team.
6/2/2015Page 1 SOA Development and Deployment B. Ramamurthy.
EGEE is a project funded by the European Union under contract IST Technologies for Building Grids 15 th October
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.
Lecture 10: Web Services. Outline Overview of Web Services Create a Web Service with Sun J2EE (JAX-RPC)
1 Web Services – Part II CS , Spring 2008/9.
Java RMI, JAX-RPC and JWSDP
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Distributed Web Software  Presentation-based, e.g., dynamic web pages  Service-based – Web Services.
Communication in Distributed Systems –Part 2
Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Web Services (tying it all together) and Introduction to Grid Services Concepts These slides are adapted from course material developed by Barry Wilkinson,
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
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.
WSDL Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Grid Computing, B. Wilkinson, 20043b.1 Web Services Part II.
COP 4991 Component Based Software Development Lecture #4 Java Web Services Onyeka Ezenwoye.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
WEB SERVICE DESCRIPTION LANGUAGE ( WSDL) -SIVA SAGAR TELLA.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
1 WSDL Tutorial Heather Kreger (borrowed from Peter Brittenham) Web Services Architect IBM Emerging Technologies.
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE CLIENT.
Enabling Grids for E-sciencE PPARC Summer School, May 2005 Web Service Tools Oliver Malham, National e-Science Centre, Edinburgh Based.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 43 Remote Method Invocation.
ASP.NET Web Services.  A unit of managed code installed under IIS that can be remotely invoked using HTTP.
Java Enterprise Edition Programming Page 1 of 9Configuring Servlets Web Application Context Name  In multiple web applications, a “context name” is used.
WSDL : Web Service Definition Language Dr. Yuhong Yan NRC-IIT-Fredericton Internet logic.
EGEE is a project funded by the European Union under contract IST SOAP Simple Object Access Protocol 3 – 4 June
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
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.
 2003 Prentice Hall, Inc. All rights reserved Deploying a Web Application ( may include.war )
Web Service Definition Language. Web Services: WSDL2 Web Service Definition Language ( WSDL ) What is a web service? [ F. Leymann 2003 ] A piece of code.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
WP3 Implementing R-GMA grid services in GT3 Abdeslem Djaoui & WP3 Grid Services Task Force 7 th EU Datagrid meeting 26/09/2003
1 Web services for DIP LDIWG meeting C.H.Sicard 7 Jan 2003.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
Beginning 자바 웹 서비스 웹 서비스 호출 Meilan JIANG Cyber infrastructure Research Laboratory Department of Advanced Technology.
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.
INFSO-RI Enabling Grids for E-sciencE Web services tools David Fergusson.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 29 Remote Method.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Chapter 5 Remote Procedure Call
WSDL JAX-RPC 17th October 2004
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.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Chapter 40 Remote Method Invocation
Introduction to Web Services
Understanding Web Services based on dev. java
Quiz Points 4 Rules Raise your hand if you know the question
Chapter 46 Remote Method Invocation
WebServices Using JAX-RPC
Introduction to Web Services
Chapter 46 Remote Method Invocation
Distributed System using Web Services
Presentation transcript:

EGEE is a project funded by the European Union under contract IST WSDL JAX-RPC 17 th October

WSDL, 17 th October JAX-RPC API packages javax.xml.rpcCore classes for the client side programming model javax.xml.rpc.encodingJava primatives XML SOAP messages javax.xml.rpc.handlerprocessing XML messages javax.xml.rpc.handler.soap javax.xml.rpc.holderssupport the use of IO parameters javax.xml.rpc.serverminimal API for web service inplementation Javax.xml.rpc.soapspecific SOAP bindings

WSDL, 17 th October JAX-RPC Architecture

WSDL, 17 th October Java web service flow

WSDL, 17 th October Client operation modes JAX-RPC allows two modes of operation  Synchronous request – response  One-way RPC Synchronous  This involves blocking the client until it receives a response  Is similar to a traditional java method call One – way  No client blocking  Service performs a operation without replying.  Not analogous to traditional method calls

WSDL, 17 th October Comparing One-way and traditional methods A traditional java method call like  Public void request (int arg1, int arg2);  Does not return a value to the caller  However if it appeared in a web service interface definition it would be mapped to a synchronous request – response RPC  This is because it indicates that an exception may still need to be thrown to the client.  A one – way RPC cannot throw an exception.

WSDL, 17 th October Synchronous method invocation Client Servlet Client invokes service Response returned to client Client waits until Server responds Server performs the requested action

WSDL, 17 th October One – way RPC invocation Client Servlet Client invokes service Server performs the requested action Client does not block While operation is performed

WSDL, 17 th October Defining a service A service can be defined starting with:  A java interface  A WSDL document Which to use?  If the service end point interface is defined in java it may not be interoperable with services/clients defined in other languages  If the service is initially defined in WSDL it will be open

WSDL, 17 th October Using JAX-RPC to create a service from a Java interface

WSDL, 17 th October Binding Parameters and Return Values with JAX-RPC

WSDL, 17 th October Interface method definitions The interface must extend java.rmi.remote Interface methods must declare that it throws java.rmi.RemoteException Service dependent exceptions can be thrown if they are checked exceptions derived from java.lang.Exception Method name-overloading is permitted Service endpoint interfaces may be extensions of other interfaces A java web service end point interface must obey the following rules:

WSDL, 17 th October Supported data types Java primitives (eg. bool, int, float, etc) Primitive wrappers ( Boolean, Interger, Float, etc) Standard java classes (required - java.lang.String, java.util.Calendar, java.util.Date, java.math.BigDecimal, java.math.BigInterger ) Value types Holder classes Arrays (where all elements are supported types) Object by reference is not supported

WSDL, 17 th October Value Types Class has a public no-argument constructor May be extended from any other class, may have static and instance methods, may implement any interface (except java.rmi.Remote and any derived) May have static fields, instance fields that are public, protected, package private or private but these must be supported types.

WSDL, 17 th October Warning about comparing classes The values returned by service methods are in fact local classes created by JAX-RPC from the XML serialisation This means that comparisons using == should be avoided equals () should be used instead (inner static classes will not compare correctly)

WSDL, 17 th October Serializer If you want to pass an un-supported java class you have to create your own serializer/deserializer to translate to and from XML. This not a trivial task as there is no JAX-RPC framework.

WSDL, 17 th October Client side Implementation

WSDL, 17 th October wscompile Generates  Compiled class files + optionally source files for stubs to interface with client side JAX-RPC  WSDL file  Model file Example commandline wscompile –gen:client –d output/client –classpath classpath config-file (add –keep –s to retain java source files)

WSDL, 17 th October config.xml <service name=“……..” targetNamespace=“………………………” typeNamespace=“……………………………..” packageName=“……………………………….”> name = name of service targetNamespace = namespace of WSDL for names associated with the service eg. port type typeNamespace = namespace of WSDL for data types packageName = name of java package

WSDL, 17 th October Generated files Some of the client side generated files: ServiceService.java Service_Impl.java Service_SerializerRegistry.java ExceptionServiceException_SOAPSerializer.java ServiceException_SOAPBuilder.java Value typeInfo_SOAPSerializer.java Info_SOAPBuilder.java InterfaceInterface_Stub.java method.java

WSDL, 17 th October Service.java file The Service.java file corresponds to the definition of the interface for the web service, ie it contains the same info as the element in the config file. package servicePackage; import javax.xml.rpc.*; Public interface Service extends javax.aml.rpc.Service { public servicePackage getServicePort(); }

WSDL, 17 th October Stub Communication Model

WSDL, 17 th October Referencing the stub In order to get an object to reference the stub you have to instantiate Service_Impl.  (Unfortunately this name is only recommended) Service_Impl service = new Service_Impl (); value* name = (value)service.getServicePort (); With this reference you can call the methods of the service.

WSDL, 17 th October Stub Interface (javax.xml.rpc.Stub) Public interface Stub { public abstract Object _getProperty (String name) throws JAXRPCException; public abstract Iterator _getPropertyNames (); public abstract void _setProperty(String name, Object value) throws JAXRPCException; } These methods allow the stub to be configured by setting various properties.

WSDL, 17 th October Stub configuration Property nametypedescription ENDPOINT_ADDRESS_PROPERTY StringAddress of the service to connect SESSION_MAINTAIN_PROPERTY BoolWhether to enter and maintain session – default false USERNAME_PROPERTY PASSWORD_PROPERTY StringAuthentication required for HTTP

WSDL, 17 th October Server side Implementation

WSDL, 17 th October Deploying to a web container Create a WAR file  Java class file for service endpoint interface  Java class files for service implementation and resources  web.xml file containing deployment information  Class files for JAX-RPC tie classes JAX-RPC tie classes are implementation specific.

WSDL, 17 th October Deploying with JWSDP - Tomcat

WSDL, 17 th October Additional WAR files required for JWSDP WEB-INF/web.xml Web application deployment descriptor WEB-INF/jaxrpc-ri.xml JWSDP-specific deployment information WEB-INF/model Model file generated by wscompile

WSDL, 17 th October web.xml file <!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN” “ Service Name A web service application

WSDL, 17 th October Creating a deployable WAR file wsdeploy –o targetFileName portableWarFileName The process is informed by the content of the jaxrpc-ri.xml file. The archive contains: class files and resources compiled class files for the ties compiled class files for serializers WSDL (in WEB-INF directory) model file for the service ( in WEB-INF) modified web.xml file jaxrpc-ri-runtime.xml (based on jaxrpc-ri.xml )

WSDL, 17 th October Package Structure for JAX-RPC Service Endpoint

WSDL, 17 th October Modified web.xml <!DOCTYPE web-app PUBLIC “-//Sun Microsystems, Inc. //DTD Web Application 2.3//EN” “ Service name …………………… com.sun.xml.rpc.server.http.JAXRPCContextListener Servlet Servlet. ………………... com.sun.xml.rpc.server.http.JAXRPCServlet 1 Servlet /Servlet

WSDL, 17 th October jaxrpc-ri.xml file <webServices xmlns=“ version=“1.0” targetNamespaceBase=“ {WSDL file location} ” typeNamespaceBase=“ {types} “> <endpoint name =“Servicename” displayname=“Servicename Port” description=“………………..” model=“/WEB-INF/model” interface=“ classpath “ implementation=“ classpath “/> endpointName=“Service” urlPattern=“ /Service “/> </webServices May contain any number of endpoint elements and any number of endpointMapping The file is private to JAX-RPC and you don’t need to edit it

WSDL, 17 th October Using JAX-RPC to create a service from a WSDL definition

WSDL, 17 th October WSDL is an interface definition

WSDL, 17 th October Getting the WSDL WSDL can be downloaded from a UDDI registry If the service uses JAXRPCServlet you can attach ?WSDL (or ?model ) to the URL request to get the WSDL (or model file).  Eg

WSDL, 17 th October A config.xml file Format of config file depends on whether wscompile is given a WSDL file, model file or Java

WSDL, 17 th October Generate client side artifacts wscompile –gen:client –keep –s generated/client –d output/client –classpath classpath config.xml

WSDL, 17 th October J2EE 1.4 bug In some versions of J2EE 1.4 generated WSDL files contain errors in the definitions tag and have to be manually edited. Eg. Which would have to be edited to

WSDL, 17 th October Some of the client side files generated by wscompile from WSDL ServiceService.java Service_Impl.java Service_SerializerRegistry.java ExceptionServiceException.java ServiceException_SOAPSerializer.java ServiceException_SOAPBuilder.java Value typeInfo.java Info_SOAPSerializer.java Info_SOAPBuilder.java InterfaceInterface_Stub.java method.java

WSDL, 17 th October Stub interface Service_Impl service = new Service_Impl (); Object name = (Object)service.getServicePort(); Info[] name = Service.getServiceInfo(); The web service address is preconfigured using information from the WSDL element within the service’s element for its portType.

WSDL, 17 th October J2EE client J2EE allows container-resident clients to get references to Service objects defined in the JNDI environment. So code can be vendor independent The client has to be packaged in a JAR file to be deployed.

WSDL, 17 th October JAR application client entry To create the entry in the JNDI environment you include a webservicesclient.xml file in the JAR This file resides in the META-INF directory

WSDL, 17 th October webservicesclient.xml file <!DOCTYPE webservicesclient PUBLIC “-//IBM Corporation, Inc//DTD J2EE Web services client 1.0//EN” “ _services_client_1_0.dtd”> …………… service/Service classpath Filename.wsdl META-INF/model

WSDL, 17 th October Elements defines the reference to the web service defines where the reference appears in the JNDI relative to java:comp/env fully qualified path to the generated class location of WSDL file relative to the root of the JAR file. mapping of WSDL definition to java service endpoint interface

WSDL, 17 th October Generation The information in the webservicesclient.xml file is read by the deployment tools. These generate a class which implements the Service interface They also generate the client side stubs which the application will call.

WSDL, 17 th October Obtaining a Service object InitialContext ctx = new InitialContext (); Object service = (object)PortableRemoteObject.narrow (ctx.lookup (“java:comp/env/service/Service”), object.class); Object name = (object)service.getServicePort(); ((Stub)name)._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, args[0]);

WSDL, 17 th October wscompile You can use the information in a config.xml file which specifies a WSDL definition to generate the classes required for the service: wscompile –import –f:norpcstructures –d output/interface config.xml -f:norpcstructures – avoids generating SOAP message creation classes.

WSDL, 17 th October Files required in the JAR File typeFilename Service end point interfaceClasspath.service.name Classpath.service.Info Classpath.service.Exception Service interfaceClasspath.service.Service Application implementationClasspath.client.ServiceAppClient WSDL fileService.wsdl Deployment descriptorsMETA-INF/application-client.xml META-INF/mapping.xml or META- INF/model META-INF/webservicesclient.xml Manifest fileMETA-INF/MANIFEST.MF

WSDL, 17 th October JAR file uses Deployment to the server to create stubs Source for class files for application client

WSDL, 17 th October After deployment Generated stubs are written to a file called stubs.jar The JAR also has a file called sun-j2ee-ri.xml

WSDL, 17 th October Accessing a Service Using a Dynamic Proxy

WSDL, 17 th October DII Call Interface