Summary. Griglie e Sistemi di Elaborazione Ubiqui. Corso di Laurea Specialistica in Ingegneria informatica. Lucidi delle Esercitazioni



Similar documents
Griglie e Sistemi di Elaborazione Ubiqui

Web-Service Example. Service Oriented Architecture

Web Services Development Guide: How to build EMBRACE compliant Web Services Version 2.0, 13 December 2006

EHR-IIS Interoperability Enhancement Project. Transport Layer Protocol Recommendation Formal Specification. Version 1.

Author: Gennaro Frazzingaro Universidad Rey Juan Carlos campus de Mostòles (Madrid) GIA Grupo de Inteligencia Artificial

WIRIS quizzes web services Getting started with PHP and Java

Building Web Services with XML Service Utility Library (XSUL)

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

Writing Grid Service Using GT3 Core. Dec, Abstract

Implementing SQI via SOAP Web-Services

Brekeke PBX Web Service

WSDL Example (Interface) WSDL Example (Implementation) Universal Description, Discovery and Integration. UDDI Usage

W E B S E RV I C E S D Y N A M I C C L I E N T G U I D E

A Sample OFBiz application implementing remote access via RMI and SOAP Table of contents

T320 E-business technologies: foundations and practice

Connecting to WebSphere ESB and WebSphere Process Server

How To Write A Contract Versioning In Wsdl 2.2.2

Overview of Web Services API

Oracle WebLogic Server

Consuming and Producing Web Services with Web Tools. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Enabling Grids for E-sciencE. Web services tools. David Fergusson. INFSO-RI

Developing Web Services with Apache CXF and Axis2

NetBeans IDE Field Guide

Module 13 Implementing Java EE Web Services with JAX-WS

Consuming, Providing & Publishing WS

The presentation explains how to create and access the web services using the user interface. WebServices.ppt. Page 1 of 14

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

Distributed Embedded Systems

Address Phone & Fax Internet

Getting Started with the Internet Communications Engine

Remote Method Invocation in JAVA

Designing the Service Contract

PEtALS Quick Start. PEtALS Team Roland NAUDIN - February

Web Services and their support in Java

Fachgebiet für Offene Kommunikationssysteme (OKS) VHE Web Services. Project in WS 2002/03. Björn Schünemann

ID2208 Programming Web Services

RPC over XML. Web services with Java. How to install it? Reference implementation. Setting the environment variables. Preparing the system

Implementing a Web Service Client using Java

Consuming and Producing Web Services with WST and JST. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Brekeke PBX Version 3 Web Service Developer s Guide Brekeke Software, Inc.

CS170 Lab 11 Abstract Data Types & Objects

Creating a Java application using Perfect Developer and the Java Develo...

Introduction to Object-Oriented Programming

An Introduction to Globus Toolkit 3

Developing a Web Service Based Application for Mobile Client

JAX-WS Developer's Guide

T Network Application Frameworks and XML Web Services and WSDL Tancred Lindholm

Demonstrating BC: Sending Out Mass ing v1.0

Installing Java (Windows) and Writing your First Program

Aspect Oriented Programming. with. Spring

Java Crash Course Part I

CHAPTER 5 IMPLEMENTATION OF THE PROPOSED GRID NETWORK MONITORING SYSTEM IN CRB

Joke Server example. with Java and Axis. Web services with Axis SOAP, WSDL, UDDI. Joke Metaservice Joke Server Joke Client.

Service Oriented Computing: Web Service Development. Dr. Cristian Mateos Diaz ( ISISTAN - CONICET

Web Services for Management Perl Library VMware ESX Server 3.5, VMware ESX Server 3i version 3.5, and VMware VirtualCenter 2.5

Building and Using Web Services With JDeveloper 11g

European Access Point for Truck Parking Data

Web Service Development Using CXF. - Praveen Kumar Jayaram

Crash Course in Java

Remote Method Invocation

Tutorial: Getting Started

IBM Rational Rapid Developer Components & Web Services

Web Services Resource Lifetime (WS-ResourceLifetime)

Web Services Technologies

Getting Started with Web Applications

Web Application Architecture (based J2EE 1.4 Tutorial)

Web Services Data Access and Integration The Core (WS-DAI) Specification, Version 1.0

Software agents. Web services. and. F. Dignum Utrecht University

API Guide. SilkCentral Test Manager

Ambientes de Desenvolvimento Avançados

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Service Oriented Computing: SOAP, WSDL and UDDI. Dr. Cristian Mateos Diaz ( ISISTAN - CONICET

Web Services ( )

Web services with WebSphere Studio: Build and test

CS506 Web Design and Development Solved Online Quiz No. 01

Table of Contents. Java CGI HOWTO

How To Test A Load Test On A Java Testnet 2.5 (For A Testnet) On A Test Server On A Microsoft Web Server On An Ipad Or Ipad (For An Ipa) On Your Computer Or Ipa

Stateful Web Services Practical

Onset Computer Corporation

Pre-authentication XXE vulnerability in the Services Drupal module

Service Data and Notifications

As with any journey, it s probably best to start with a map of the terrain.

AP Computer Science Java Subset

Realizing Enterprise Integration Patterns in WebSphere

JBoss Portlet Container. User Guide. Release 2.0

H2O A Lightweight Approach to Grid Computing

04 XML Schemas. Software Technology 2. MSc in Communication Sciences Program in Technologies for Human Communication Davide Eynard

Send your request via a SOAP-Request (e.g. with DotNET/SOAP, Java, PHP) to he following URL of our server:

Grid Computing. Web Services. Explanation (2) Explanation. Grid Computing Fall 2006 Paul A. Farrell 9/12/2006

How To Create A C++ Web Service

MDM Server Web Services Reference Guide (Internal)

Web Services Development for IBM WebSphere App Server V7.0 Exam.

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

Introduction to XML. Data Integration. Structure in Data Representation. Yanlei Diao UMass Amherst Nov 15, 2007

HOBOlink Web Services V2 Developer s Guide

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Hello World RESTful web service tutorial

Web Services using Tomcat and Eclipse

Programming with Android: SDK install and initial setup. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Continuous Integration Part 2

Transcription:

Griglie e Sistemi di Elaborazione Ubiqui Corso di Laurea Specialistica in Ingegneria informatica Lucidi delle Esercitazioni Anno Accademico 2005/2006 Ing. Antonio Congiusta Ing. Antonio Congiusta 1 Summary 5 steps to writing a service Compilation and GAR generation Hello World example MathService example WSDL details Java implementation details Ing. Antonio Congiusta 2

Developing GT4 Web Services: 5 easy steps Step 1. Define the service s interface. Must write a Web Service Description Language (WSDL) file describing the service s abstract interface (must be done by hand). Step 2. Implement the service. Develop Java routines for the service implementation If WSRF mechanisms are used, also for associated resource properties. Step 3. Define deployment parameters: Write a Web Services Deployment Descriptor (WSDD) and a JNDI file that describes various aspects of the service s configuration. Step 4. Compile everything and generate a GAR file. Compilation generates application specific interface routines that handle the demarshalling/marshalling of the Web service s arguments from/to SOAP messages. Step 5. Deploy the service. Ing. Antonio Congiusta 3 Create a GAR file with Ant However, creating a GAR file is a pretty complex task which involves the following: Processing the WSDL file to add missing pieces (such as bindings) Creating the stub classes from the WSDL Compiling the stubs classes Compiling the service implementation Organize all the files into a very specific directory structure Ing. Antonio Congiusta 4

Create a GAR file with Ant Ing. Antonio Congiusta 5 The globus- build- service script and buildfile./globus globus- build- service.sh -d d <service< base directory> -s s <service' < service's s WSDL file> The "service" base directory" " is the directory where we placed the deploy-server.wsdd file, and where the Java files can be found (inside a src directory). If everything works fine, the GAR file generated will be something like: $EXAMPLES_DIR/org_globus_examples_HelloWorld.gar Ing. Antonio Congiusta 6

Deploy the service into a GT4 container Deployment is done with a GT4 tool that, using Ant, unpacks the GAR file and copies the files (WSDL, compiled stubs, compiled implementation,, WSDD) into appropriate locations in the GT4 directory tree. This deployment command must be run with a user that has write permission in $GLOBUS_LOCATION. globus-deploy deploy-gar $EXAMPLES_DIR/org_globus_examples_HelloService.gar There is also a command to undeploy a service: globus-undeploy undeploy-gar org_globus_examples_helloservice Ing. Antonio Congiusta 7 A Simple Client public static void main(string String[] args) ) { HelloServiceAddressingLocator locator = new HelloServiceAddressingLocator(); try { String serviceuri=args[0]; EndpointReferenceType endpoint = new EndpointReferenceType(); endpoint.setaddress(new Address(serviceURI)); HelloWorldPortType myport = locator.gethelloworldporttypeport(endpoint endpoint); // Perform some operations GetResourcePropertyResponse response = port.getresourceproperty(helloqnames.rp_name); String result = myport.echo( First invocation"); response = myport.getresourceproperty(helloqnames.rp_name); System.out.println(AnyHelper.toSingleString AnyHelper.toSingleString( response));... catch (Exception( e) {e.printstacktrace(); Ing. Antonio Congiusta 8

A Simple Client First, we create an EndpointReferenceType Next, we obtain a reference to the service's porttype Once we have that reference, we can work with the web service as if it were a local object. For example, to invoke the remote echo operation Finally, notice how all the code must be placed inside a try/catch block. We must always do this, since all the remote operations can throw RemoteExceptions (for example, if there is a network failure and we can't t contact the service). Ing. Antonio Congiusta 9 A Simple Client We are now going to compile the client. Before running the compiler, make sure you run the following: source $GLOBUS_LOCATION/etc/globus-devel devel-env.shenv.sh The globus-devel devel-env.shenv.sh script takes care of putting all the Globus libraries into your CLASSPATH. When compiling the service, Ant took care of this but, since we're not using Ant to compile the client, we need to run the script. To compile the client, do the following: javac \ -classpath./build/stubs/classes/:$classpath \ org/globus globus/examples/clients/helloservice_instance/cli ent.java./build/classes is a directory generated by Ant were all the compiled stub classes are placed. We need to include this directory in the CLASSPATH so our client can access generated stub classes such as HelloServiceAddressingLocator. Ing. Antonio Congiusta 10

Running the Container Now, before running the client, we need to to start up the standalone container. Otherwise, our web service won't be available,, and the client will crash. globus-start start-container -nosec When the container starts up, you'll see a list with the URIs of all the deployed services. http://127.0.0.1:8080/wsrf wsrf/services/examples/helloserv ice This is the service as it would appear in a default GT4 installation, with the standalone container located in http://localhost localhost:8080/ :8080/wsrf/services. If the service is correctly deployed, we can now run the client: java \ -classpath./build build/stubs/classes/: /:$CLASSPATH \ org.globus.examples.clients.helloservice_instance.clie nt \ http://127.0.0.1:8080/wsrf wsrf/services/examples/helloserv ice Ing. Antonio Congiusta 11 5 Steps to Writing a Service Step 1: Define the interface in WSDL what operations will be available to clients the service interface is called the port type (porttype). Step 2: Implement the service in Java Service Service resource Service home Step 3: Configure the deployment WSDD (and JNDI) Step 4: Create a GAR file with Ant Step 5: Deploy the service into a Web services container Ing. Antonio Congiusta 12

Top-down approach We use the top-down approach.. The WSDL contains the abstract definition of the service including types, messages and porttypes. Starting with a document/literal WSDL and then generating the Java artifacts from that leads to the most interoperability. We use some of the tools that come with the GT4 toolkit to generate the binding and stubs. WSDL interface Java interface Java Implementation Ing. Antonio Congiusta 13 Tutorial Example: MathService Supports the operations: Add Subtract Has the following properties Value (integer) Last operations performed (string) On initialization: Value set to zero Last op set to NONE Ing. Antonio Congiusta 14

Step 1: Define the interface in WSDL: Two options Writing the WSDL directly. This is the most versatile option. Total control over the description of our porttype. Generating WSDL from a Java interface. The easiest option, but very complicated interfaces are not always converted correctly to WSDL Ing. Antonio Congiusta 15 The interface in Java public interface Math { public void add(int a); public void subtract(int a); public int getvaluerp(); Ing. Antonio Congiusta 16

WSDL structure * * <import> incorporate external definitions <types> logic structure of data being transmitted * <message> transmittable messages * <schema> <porttype> interface operations and assoc. messages * <binding> how messages will be transmitted * <service> how a service is accessed * * <part> * <operation> * <MESSAGETYPE> <port> web-address * * <TYPE> ref Ing. Antonio Congiusta 17 Abstract Physical Steps to WSDL: key TAGS Write the root element <definitions> Write the <PortType> It has 2 resource properties Write an input and output <message> for each operation in the PortType. Write the <types> Ing. Antonio Congiusta 18

Root Element -- <definitions> <?xml version="1.0" encoding="utf-8"?> <definitions name="mathservice" targetnamespace="http://www.globus.org/namespaces/2004/02/prog tutorial/mathservice" xmlns:tns="http://www.globus.org/namespaces/2004/02/progtutori al/mathservice" xmlns:ogsi="http://www.gridforum.org/namespaces/2003/03/ogsi" xmlns:gwsdl="http://www.gridforum.org/namespaces/2003/03/gridw SDLExtensions" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns=http://schemas.xmlsoap.org/wsdl/... /definitions> <definitions> TAG as 2 important properties: name: : the name of the WSDL file.. Not related with the name of the PortType targetnamespace: : The target namespace of the GWSDL file. Ing. Antonio Congiusta 19 <import > TAG used to import WSDL files You don t have to import all WSDL files, just the ones you plan to use <import location="../../ ="../../wsrf/properties/ws- ResourceProperties.wsdl" namespace="http://docs.oasis ="http://docs.oasis-open.org/wsrf/2004/06/wsrf- WS-ResourceProperties ResourceProperties-1.2-draft-01.wsdl" /> Ing. Antonio Congiusta 20

Write the PortType <definitions... > <porttype name="mathporttype" wsdlpp:extends="wsrpw:getresourceproperty" wsrp:resourceproperties="tns:mathresourceproperties"> <operation name="add"> <input message="tns:addinputmessage"/> <output message="tns:addoutputmessage"/> </operation> <operation name="subtract"> <input message="tns:subtractinputmessage"/> <output message="tns:subtractoutputmessage"/> </operation> <operation name="getvaluerp"> <input message="tns:getvaluerpinputmessage"/> <output message="tns:getvaluerpoutputmessage"/> </operation> </porttype> </definitions> Ing. Antonio Congiusta 21 <porttype> tag important attributes name: : name of the PortType wsdlpp:extends: One of the main differences with plain WSDL. Part of preprocessor provided by Globus Allow definition of PortType as an extension of an existing PortType. In this example we tell preprocessor to include GetResourceProperty and ImmediateResourceTermination Ing. Antonio Congiusta 22

<porttype> tag important attributes wsrp:resourceproperites: Specifies service resource properties An <operation> tag for each method in the PortType Operation tag has an input tag, an output tag, and a fault tag Input/output tags have a message attribute, which specifies what message should be passed along when the operation is invoked and returns Ing. Antonio Congiusta 23 Write input and output messages for each port type <message name="addinputmessage"> <part name="parameters" element="tns:add"/> </message> <message name="addoutputmessage"> <part name="parameters" element="tns:addresponse"/> </message> Messages are composed of parts these messages have one part,, in which a single XML element is passed along Ing. Antonio Congiusta 24

Define the XML elements inside the <types> tag The <types> tag contains an <xsd:schema< xsd:schema> > tag. <types> <xsd:schema targetnamespace="http://www.globus.org/namespaces/2004/02/progt utorial/mathservice" attributeformdefault="qualified" elementformdefault="qualified" xmlns="http://www.w3.org/2001/xmlschema"> <xsd:element name="add"> <xsd:complextype> <xsd:sequence> <xsd:element name="value" type="xsd:int"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="addresponse"> <xsd:complextype/> </xsd:element> </xsd:schema> </types> Ing. Antonio Congiusta 25 Multiple XML elements inside <types> tag <types> <xsd:schema targetnamespace="http://www.globus.org/namespaces/2004/02/p rogtutorial/mathservice" attributeformdefault="qualified" elementformdefault="qualified" xmlns="http://www.w3.org/2001/xmlschema"> <xsd:element name="add"> <xsd:complextype> <xsd:sequence> <xsd:element name="value1" type="xsd:int"/> <xsd:element name="value2" type="xsd:int"/> </xsd:sequence> </xsd:complextype> </xsd:element> <xsd:element name="addresponse"> <xsd:complextype/> </xsd:element> </xsd:schema> </types> Ing. Antonio Congiusta 26

Declaring the resource properties Example slide: declaration specifies that MathResourceProperties contains two resource properties, Value and LastOp,, each of which appear only once (we could specify array resource properties by changing the values of maxoccurs). It is important to notice No bindings: Bindings are an essential part of a normal WSDL file. However, we don't have to add them manually, since they are generated automatically by a GT4 tool that is called when we build the service. Ing. Antonio Congiusta 27 <types> <xsd:schema targetnamespace="http://www.globus.org/namespaces/examples/core/mathservice_instance" xmlns:tns="http://www.globus.org/namespaces/examples/core/mathservice_instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <! Resource Properties--> <xsd:element name="value" type="xsd:int"/> <xsd:element name="lastop" type="xsd:string"/> <xsd:element name="mathresourceproperties"> <xsd:complextype> <xsd:sequence> <xsd:element ref="tns:value" minoccurs="1" maxoccurs="1"/> <xsd:element ref="tns:lastop" minoccurs="1" maxoccurs="1"/> </xsd:sequence> </xsd:complextype> </xsd:element> </xsd:schema> </types> Ing. Antonio Congiusta 28

Step 2: Implement the Service package org.globus.examples.services.core.first.impl; import java.rmi.remoteexception; import org.globus.wsrf.resource; import org.globus.wsrf.resourceproperties; import org.globus.wsrf.resourceproperty; import org.globus.wsrf.resourcepropertyset; import org.globus.wsrf.impl.reflectionresourceproperty; import org.globus.wsrf.impl.simpleresourcepropertyset; import org.globus.examples.stubs.mathservice_instance.addresponse; import org.globus.examples.stubs.mathservice_instance.subtractrespo nse; import org.globus.examples.stubs.mathservice_instance.getvaluerp; public class MathService implements Resource, ResourceProperties { Ing. Antonio Congiusta 29 Service implementation Since our Java class will implement both the service and the resource, we need to implement the Resource interface. However, this interface doesn't require any methods. It is simply a way of tagging a class as being a resource. By implementing the ResourceProperties interface we are indicating that our class has a set of resource properties which we want to make available. This interface requires that we add the following to our class: private ResourcePropertySet propset; public ResourcePropertySet getresourcepropertyset() { return this.propset; Ing. Antonio Congiusta 30

public class MathService implements Resource, ResourceProperties { /* Resource Property set */ private ResourcePropertySet propset; /* Resource properties */ private int value; private String lastop; /* Get/Setters for the RPs */ public int getvalue() { return value; public void setvalue(int value) { this.value = value; public String getlastop() { return lastop; Public class MathService public void setlastop(string lastop) ) { this.lastop = lastop; /* Required by interface ResourceProperties */ public ResourcePropertySet getresourcepropertyset() { return this.propset; Ing. Antonio Congiusta 31 The QNames interface When we have to refer to just about anything related to a service, we will need to do so using its qualified name, or QName for short. This is a name which includes a namespace and a local name. For example,, the QName of the Value RP is: {http://www.globus.org/namespaces namespaces/examples/core/ MathService_instanceValue A qualified name is represented in Java using the QName class package org.globus.examples.services.core.first.impl; import javax.xml.namespace.qname; public interface MathQNames { public static final String NS = "http://www.globus.org/namespaces namespaces/examples/core/ /core/mathservice_instan ce"; public static final QName RP_VALUE = new QName(NS, "Value"); public static final QName RP_LASTOP = new QName(NS, "LastOp" LastOp"); public static final QName RESOURCE_PROPERTIES = new QName(NS, "MathResourceProperties"); Ing. Antonio Congiusta 32

Public class MathService Next, we have to implement the constructor. Here we will initialize the resource properties. /* Constructor. Initializes RPs */ public MathService() throws RemoteException { this.propset = new SimpleResourcePropertySet( MathQNames.RESOURCE_PROPERTIES); /* Initialize the RP's */ try { ResourceProperty valuerp = new ReflectionResourceProperty( MathQNames.RP_VALUE,, "Value", this); this.propset.add(valuerp); setvalue(0); ResourceProperty lastoprp = new ReflectionResourceProperty( MathQNames.RP_LASTOP,, "LastOp" LastOp", this); this.propset.add(lastoprp); setlastop("none"); "); catch (Exception e) { throw new RuntimeException(e.getMessage()); ()); Università della Calabria - Griglie e Sistemi di Elaboraz. Ubiqui A.A. 05/06 Ing. Antonio Congiusta 33 Operation implementation public AddResponse add(int a) throws RemoteException { value += a; lastop = "ADDITION"; return new AddResponse(); You'll notice that, even though we defined the add operation as having no return type in the WSDL file, now the return type is AddResponse.. A similar thing happens in the getvaluerp method: public int getvaluerp(getvaluerp params) throws RemoteException { return value; Ing. Antonio Congiusta 34

Boxed parameters The parameters and the return values will in some cases be 'boxed'' inside stub classes (which are generated automatically from the WSDL file). This is more evident when we have several parameters. For example, if we declared the following operation in our WSDL file: void multiply(int int a1, int a2); The actual Java code would look like this: public MultiplyResponse multiply(multiply params) throws RemoteException { int a1 = params.geta1() int a2 = params.geta2() // Do something return new MultiplyResponse(); Multiply and MultiplyResponse are stub classes. Notice how the two parameters (a1 and a2) are 'boxed' inside a single Multiply parameter,, and how we return a MultiplyResponse object, even though we don't really want to return anything. Ing. Antonio Congiusta 35? Question Time??? The more you ask the less I question you!?? Ing. Antonio Congiusta 36