COMPUTACIÓN ORIENTADA A SERVICIOS (PRÁCTICA) Dr. Mauricio Arroqui EXA-UNICEN



Similar documents
Maven2. Configuration and Build Management. Robert Reiz

Presentation of Enterprise Service Bus(ESB) and. Apache ServiceMix. Håkon Sagehaug

Hands on exercise for

HPN Product Tools. Copyright 2012 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.

Consuming a Web Service(SOAP and RESTful) in Java. Cheat Sheet For Consuming Services in Java

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE

New Server Installation. Revisión: 13/10/2014

Manejo Basico del Servidor de Aplicaciones WebSphere Application Server 6.0

Continuous integration in OSGi projects using Maven (v:0.1) Sergio Blanco Diez

Propiedades del esquema del Documento XML de envío:

Práctica 1: PL 1a: Entorno de programación MathWorks: Simulink

Hello World RESTful web service tutorial

Web Service Development Using CXF. - Praveen Kumar Jayaram

Sales Management Main Features

ECCAIRS 5 Instalación

Software Design Document Securing Web Service with Proxy

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

Apéndice C: Código Fuente del Programa DBConnection.java

Técnicas Avanzadas de Inteligencia Artificial Dpt. Lenguajes y Sistemas Informáticos. FISS. UPV-EHU

DIPLOMADO DE JAVA - OCA

Module 13 Implementing Java EE Web Services with JAX-WS

Controlling Web Application Behavior

Web Services in Eclipse. Sistemi Informativi Aziendali A.A. 2012/2013

AV-002: Professional Web Component Development with Java

ISC Spain. Enjoy a unique experience.

Web Application Architecture (based J2EE 1.4 Tutorial)

Problem 1 (1.5 points)

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

WIRIS quizzes web services Getting started with PHP and Java

Overview of Web Services API

OMEGA SOFT WF RISKEVAL

Developing Web Services with Apache CXF and Axis2

HELIO Storage Service Developers Guide Draft

by Charles Souillard CTO and co-founder, BonitaSoft

Jukka Kokko SOFTWARE BUILD AND RELEASE MANAGEMENT FOR A WIRELESS PRODUCT WITH OPEN SOURCE TOOLS

Content. Development Tools 2(63)

Maven or how to automate java builds, tests and version management with open source tools

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

J Intercultural communica0on, mee0ngs and nego0a0ons Seminars and case studies

CC68J APLICACIONES EMPRESARIALES CON JEE JSF. Profesores: Andrés Farías

Visión general de la integración con asanetwork

Enter Here ->> Superar la depresionantidepresivos

Networks and Services

Verbos modales. In this class we look at modal verbs, which can be a tricky feature of English grammar.

Web Container Components Servlet JSP Tag Libraries

Citrix User Profile Manager - Citrix UPM

Copyright TeachMe.com 242ea 1

Tutorial. Christopher M. Judd

Consuming, Providing & Publishing WS

LINIO COLOMBIA. Starting-Up & Leading E-Commerce. Luca Ranaldi, CEO. Pedro Freire, VP Marketing and Business Development

Build management & Continuous integration. with Maven & Hudson

Arjun V. Bala Page 20

Integration with Other Tools

Please note that the print size cannot be smaller than the text in the document.

Aspects of using Hibernate with CaptainCasa Enterprise Client

GETTING TO KNOW ARCGIS MODELBUILDER KAMBAMBA.NET 1/7 GETTING-TO-KNOW-ARCGIS-MODELBUILDER.PDF

Spanish 8695/S Paper 3 Speaking Test Teacher s Booklet Time allowed Instructions one not not Information exactly as they are printed not 8695/S

Developer Guide: Smartphone Mobiliser Applications. Sybase Mobiliser Platform 5.1 SP03

HOBOlink Web Services V2 Developer s Guide

Maven2 Reference. Invoking Maven General Syntax: Prints help debugging output, very useful to diagnose. Creating a new Project (jar) Example:

Web-Service Example. Service Oriented Architecture

DIPLOMADO EN BASE DE DATOS

CONCEPTS OF INDUSTRIAL AUTOMATION. By: Juan Carlos Mena Adolfo Ortiz Rosas Juan Camilo Acosta

Summer Reading and Class Assignments Rising Seniors

Work Instruction (Instruccion de Trabajo) Wistron InfoComm (Texas) Corp.

Tema 7 GOING TO. Subject+ to be + ( going to ) + (verb) + (object )+ ( place ) + ( time ) Pronoun

How To Implement Lightweight ESOA with Java

Mind The Gap! Setting Up A Code Structure Building Bridges

Web Services using Tomcat and Eclipse

Using ilove SharePoint Web Services Workflow Action

Brekeke PBX Web Service

Controller annotati. con Spring MVC 2.5

Quartz.Net Scheduler in Depth

Integrating your Maven Build and Tomcat Deployment

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

Diplomado Certificación

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

D755M CONTROL CARD FOR TWO SINGLE-PHASE MOTORS 220/230 VAC TARJETA DE MANDO PARA DOS MOTORES MONOFÁSICOS 220/230 VAC INSTALLATION GUIDE

VMware vsphere with Operations Management: Fast Track

Software project management. and. Maven

General Certificate of Education Advanced Level Examination June 2014

Ehcache Web Cache User Guide. Version 2.9

Web Service Caching Using Command Cache

OpenOffice.org Extensions development in Java with NetBeans in practise. Jürgen Schmidt OpenOffice.org Sun Microsystems, Inc.

Implementing SQI via SOAP Web-Services

LOS ANGELES UNIFIED SCHOOL DISTRICT REFERENCE GUIDE

Programma corso di formazione J2EE

CONSENT OF THE GOVERNED EL CONSENTIMIENTO DE LOS GOBERNADOS EXTENDING. Founding Principles for English Language Learners

Onset Computer Corporation

WEB SERVICES WEB SERVICES

on - encima de under - debajo de in - en inside - adentro outside - afuera in front of - en frente de behind - atrás next to - al lado between -

ZONING BOARD OF ADJUSTMENT: INFORMATION AND GUIDELINES

CITY OF LAREDO Application for Certification of Compliance for Utility Connection ($ Application Fee Ordinance No.

PicketLink Federation User Guide 1.0.0

Web Applications. For live Java training, please see training courses at

INTELIGENCIA DE NEGOCIO CON SQL SERVER

Cambridge IGCSE.

Transcription:

COMPUTACIÓN ORIENTADA A SERVICIOS (PRÁCTICA) Dr. Mauricio Arroqui EXA-UNICEN

Actividad Crear un servicio REST y un cliente para el mismo ejercicio realizado durante la práctica para SOAP. Se requiere la modelación del problema y correcta utilización de los verbos. A continuación se ejemplifica paso a paso la creación de un servicio Rest y un cliente en Eclipse.

Server

Convertir a Maven Project (simplifica el agregado de librerías) Click derecho en el Proyecto -> Configure Convert to Maven Project

Convertir a Maven Project

Abrir pom.xml y agregar abajo del tag <build> <dependencies> <dependency> <groupid>asm</groupid> <artifactid>asm</artifactid> <version>3.3.1</version> </dependency> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-bundle</artifactid> <version>1.19</version> </dependency> <dependency> <groupid>org.json</groupid> <artifactid>json</artifactid> <version>20140107</version> </dependency> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-server</artifactid> <version>1.19</version> </dependency> <dependency> <groupid>com.sun.jersey</groupid> <artifactid>jersey-core</artifactid> <version>1.19</version> </dependency> </dependencies>

Mi pom.xml completo <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>restwebservice</groupid> <artifactid>restwebservice</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <build> <sourcedirectory>src</sourcedirectory> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>3.3</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <artifactid>maven-war-plugin</artifactid> <version>2.6</version> <configuration> <warsourcedirectory>webcontent</warsourcedirectory> <failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin> </plugins> </build> <dependencies> LAS QUE PEGAMOS </dependencies> </project>

Editar /WebContent/WEB-INF/web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/ javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/webapp_3_0.xsd" id="webapp_id" version="3.0"> <display-name>restwebservice</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.servletcontainer</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jersey Web Application</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> </web-app>

Clase Java 1 @Path("/dtopservice") public class DolarToPesoService { @GET @Produces("application/xml") public String convertctof() { Double peso; Double dolar = 10.0; peso = dolar * 9.4 * 1.2; String result = "@Produces(\"application/xml\") Output: \n\nu$d to Peso Arg Tarjeta Converter Output: \n\n" + peso; return "<dtopservice>" + "<dolar>" + dolar + "</dolar>" + "<dtopoutput>" + result + "</dtopoutput>" + "</ dtopservice>"; @Path("{c") @GET @Produces("application/xml") public String convertctoffrominput(@pathparam("c") Double c) { Double peso; Double dolar = c; peso = ((dolar * 9) / 5) + 32; String result = "@Produces(\"application/xml\") Output: \n\nu$d to Peso Arg Tarjeta Converter Output: \n\n" + peso; return "<dtopservice>" + "<dolar>" + dolar + "</dolar>" + "<dtopoutput>" + result + "</dtopoutput>" + "</ dtopservice>";

Clase Java 2 @Path("/dtopservice") public class DolarToPesoService { @GET @Produces("application/xml") public String convertctof() { Double peso; Double dolar = 10.0; peso = dolar * 9.4 * 1.2; String result = "@Produces(\"application/xml\") Output: \n\nu$d to Peso Arg Tarjeta Converter Output: \n\n" + peso; return "<dtopservice>" + "<dolar>" + dolar + "</dolar>" + "<dtopoutput>" + result + "</dtopoutput>" + "</ dtopservice>"; @Path("{c") @GET @Produces("application/xml") public String convertctoffrominput(@pathparam("c") Double c) { Double peso; Double dolar = c; peso = ((dolar * 9) / 5) + 32; String result = "@Produces(\"application/xml\") Output: \n\nu$d to Peso Arg Tarjeta Converter Output: \n\n" + peso; return "<dtopservice>" + "<dolar>" + dolar + "</dolar>" + "<dtopoutput>" + result + "</dtopoutput>" + "</ dtopservice>";

Maven Click derecho en el projecto -> Maven -> Update Project Click derecho en el projecto > Run as -> Maven Build (opción 5) ->Add clean install -> Run

Arrancar el Tomcat

Test http://localhost:8080/restwebservice/services/ dtopservice/ http://localhost:8080/restwebservice/services/ dtopservice/50/ http://localhost:8080/restwebservice/services/ ptodservice/ http://localhost:8080/restwebservice/services/ ptodservice/50/

Cliente

Estructura del proyecto 1. Creamos un paquete para el cliente. 2. Va a ser una simple clase con un método main() Paquete donde crearon el servidor

Clase Java package ar.edu.unicen.exa.client; import com.sun.jersey.api.client.client; import com.sun.jersey.api.client.clientresponse; import com.sun.jersey.api.client.webresource; public class RestWebServiceClient { public static void main(string[] args) { System.out.println("STARTING"); RestWebServiceClient client = new RestWebServiceClient(); client.getptodresponse(); client.getdtopresponse(); private void getdtopresponse() { try { Client client = Client.create(); WebResource webresource2 = client.resource("http://localhost:8080/restwebservice/services/dtopservice/10"); ClientResponse response2 = webresource2.accept("application/xml").get(clientresponse.class); if (response2.getstatus()!= 200) { throw new RuntimeException("Failed : HTTP error code : " + response2.getstatus()); String output2 = response2.getentity(string.class); System.out.println("\n============Get Dollars To Pesos Arg ============"); System.out.println(output2); catch (Exception e) { e.printstacktrace(); private void getptodresponse() { try { Client client = Client.create(); WebResource webresource = client.resource("http://localhost:8080/restwebservice/services/ptodservice/10"); ClientResponse response = webresource.accept("application/json").get(clientresponse.class); if (response.getstatus()!= 200) { throw new RuntimeException("Failed : HTTP error code : " + response.getstatus()); String output = response.getentity(string.class); System.out.println("============Get Pesos Arg to Dollar Tarjeta============"); System.out.println(output); catch (Exception e) { e.printstacktrace();

FIN