Distribution and Integration Technologies



Similar documents
02267: Software Development of Web Services

02267: Software Development of Web Services

REST API Development. B. Mason Netapp E-Series

REST web services. Representational State Transfer Author: Nemanja Kojic

Designing RESTful Web Applications

Web Services ( )

Design REST Services with CXF JAX- RS implementation: best practices and lessons learned

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

WEB SERVICES. Revised 9/29/2015

REST vs. SOAP: Making the Right Architectural Decision

WCF WINDOWS COMMUNICATION FOUNDATION OVERVIEW OF WCF, MICROSOFTS UNIFIED COMMUNICATION FRAMEWORK FOR.NET APPLICATIONS

Cross-domain Identity Management System for Cloud Environment

Building and Using Web Services With JDeveloper 11g

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

Apache. Version 1.0. Developer Guide

ITS. Java WebService. ITS Data-Solutions Pvt Ltd BENEFITS OF ATTENDANCE:

Developing Java Web Services

GlassFish. Developing an Application Server in Open Source

VB.NET - WEB PROGRAMMING

The end. Carl Nettelblad

Module 13 Implementing Java EE Web Services with JAX-WS

CERTIFIED MULESOFT DEVELOPER EXAM. Preparation Guide

ASMX

XML Processing and Web Services. Chapter 17

JVA-561. Developing SOAP Web Services in Java

JAVA API FOR XML WEB SERVICES INTRODUCTION TO JAX-WS, THE JAVA API FOR XML BASED WEB SERVICES (SOAP, WSDL)

Contents. 2 Alfresco API Version 1.0

HTTP - METHODS. Same as GET, but transfers the status line and header section only.

Introduction to WCF 3.5 and Rest

General principles and architecture of Adlib and Adlib API. Petra Otten Manager Customer Support

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

1 What Are Web Services?

REST services in Domino - Domino Access Services

September 2009 Cloud Storage for Cloud Computing

Accessing Data with ADOBE FLEX 4.6

Building SOA Applications with JAX-WS, JAX- RS, JAXB, and Ajax

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

OData in a Nutshell. August 2011 INTERNAL

1 What Are Web Services?

Creating a Structured Forms Processing Web Service Getting Started with Form Identification

Fairsail REST API: Guide for Developers

T320 E-business technologies: foundations and practice

Progress OpenEdge REST

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Securing JAX-RS RESTful services. Miroslav Fuksa (software developer) Michal Gajdoš (software developer)

Security Testing For RESTful Applications

Introduction to Web services for RPG developers

Java Web Services Training

A Comparative Study of Web Development Technologies Using Open Source and Proprietary Software

Towards Introducing and Implementation of SOA Design Antipatterns

SOA. Next Generation Open Source. Burr Sutter Sr. Product Manager, SOA (JBossESB, Riftsaw, jbpm, Drools) September 3, 2009

Web. Services. Web Technologies. Today. Web. Technologies. Internet WWW. Protocols TCP/IP HTTP. Apache. Next Time. Lecture # Apache.

Lecture 11 Web Application Security (part 1)

Enabling REST Services with SAP PI. Michael Le Peter Ha

JAVA API FOR XML WEB SERVICES (JAX-WS)

Oracle Service Bus Examples and Tutorials

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Oracle EXAM - 1Z Java EE 6 Web Services Developer Certified Expert Exam. Buy Full Product.

Apache CXF Web Services

Java EE 7: Back-End Server Application Development

WA2087 Programming Java SOAP and REST Web Services - WebSphere 8.0 / RAD 8.0. Student Labs. Web Age Solutions Inc.

Domain Name System (DNS)

Web application development landscape: technologies and models

Mobile Application Development Connecting with PHP REST Servers from Android

MathCloud: From Software Toolkit to Cloud Platform for Building Computing Services

Service Oriented Architecture

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

WEB SERVICES TEST AUTOMATION

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Implementing a Web Service Client using Java

AD-HOC QUERY BUILDER

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

Rich-Internet Anwendungen auf Basis von ColdFusion und Ajax

Oracle WebLogic Server

Web Services Development for IBM WebSphere Application Server V7.0. Version: Demo. Page <<1/10>>

An Oracle White Paper June RESTful Web Services for the Oracle Database Cloud - Multitenant Edition

10CS73:Web Programming

soapui Product Comparison

NetBeans e lo sviluppo di applicazioni Java/JavaFX per Facebook. Corrado De Bari corrado.debari@sun.com Sun Microsystems Italia

Closer Look at Enterprise Service Bus. Deb L. Ayers Sr. Principle Product Manager Oracle Service Bus SOA Fusion Middleware Division

StreamServe Persuasion SP4 Service Broker

Oracle Service Bus. Situation. Oracle Service Bus Primer. Product History and Evolution. Positioning. Usage Scenario

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

Ameritas Single Sign-On (SSO) and Enterprise SAML Standard. Architectural Implementation, Patterns and Usage Guidelines

Web Services Tutorial

Title page. Alcatel-Lucent 5620 SERVICE AWARE MANAGER 13.0 R7

Leveraging Cloud Storage Through Mobile Applications Using Mezeo Cloud Storage Platform REST API. John Eastman Mezeo

Lightweight Data Integration using the WebComposition Data Grid Service

Application layer Web 2.0

Guidelines for Implementation of REST

Cloud Powered Mobile Apps with Microsoft Azure

JVA-122. Secure Java Web Development

Reusing Existing * Java EE Applications from Oracle SOA Suite

Mobile Trillium Engine

Server based signature service. Overview

Implementation of Android Application for Faculty Employees

Transcription:

Distribution and Integration Technologies RESTful Services REST style for web services REST Representational State Transfer, considers the web as a data resource Services accesses and modifies this data (CRUD operations) This model and style was first described in 2000 in a thesis called Architectural Styles and the Design of Network-based Software Architectures (by Roy Fielding) Usual implementations uses Uri templates for naming the resources and data items Ex: http://finance.google.com/finance/info?q={stock_nick http://some_organization/crm/customer/{id Operations are performed using the HTTP protocol operation verbs. HTTP results are also important GET, POST, PUT, DELETE, HEAD Information can be transfered in a variety of formats (representations) HTML, XML, JSON, RSS, CSV,... 2010@FEUP RESTful Services 2

GET Operation verbs Retrieve the resource identified by the URI POST Send (to create) a resource to the server identified by the URI PUT Store (to modify) a resource in the server using the supplied URI DELETE Removes the resource identified by the URI HEAD Retrieve metadata (more information) about the resource identified by the URI 2010@FEUP RESTful Services 3 Information formats Usually simple formats, not supporting the complications of SOAP and their associated functionality The most used XML in a simple schema The services that use this format are also called POX (plain old XML) services JSON (JavaScript Object Notation) used in literal representations of java script objects RSS (Really Simple Syndication) and ATOM are content syndication formats and can also be used for services 2010@FEUP RESTful Services 4

REST operations POST and PUT needs a payload Clients:. Send the HTTP web request building the appropriate: URI, using the operation template and parameters In the case of a POST or PUT you need the payload, encoded appropriately. Collect the response from the server. Check the HTTP result. Decode the contents 2010@FEUP RESTful Services 5 REST services in.net Are built as the other WCF services 1. Start with a WCF Service Library project and define the contract and implementation 2. The operations in the contract must be associated with the HTTP operations using the attributes [WebGet] (for GET) and [WebInvoke] (for other HTTP operations) 3. You can define parameters in these attributes like UriTemplate, RequestFormat and ResponseFormat. Formats can be XML or JSON. Parameters in UriTemplate (between { ) must match method parameters 4. A [Description] attribute can be added for an automatic help page Example: [ServiceContract] public interface IRestService { [WebGet(UriTemplate="/users", ResponseFormat=WebMessageFormat.Json)] [Description("Gets all users stored so far.")] [OperationContract] Users GetUsers(); [WebInvoke(Method = "POST", UriTemplate = "/users", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [Description("Adds one user.")] [OperationContract] int AddUser(User user); [WebInvoke(Method="DELETE", UriTemplate="/users/{id")] [Description("Deletes one user by id.")] [OperationContract] void DeleteUser(string id); 2010@FEUP RESTful Services 6

Binding for REST services REST Services use the existing webhttpbinding and a behavior specifying the communication (webhttp) A minimal configuration file is: <system.servicemodel> <services> <service name="restservice"> <endpoint address="http://localhost:8700/rest/" behaviorconfiguration="restbehavior" binding="webhttpbinding" name="restwebservice" contract="irestservice" /> </service> </services> <behaviors> <endpointbehaviors> <behavior name="restbehavior"> <webhttp helpenabled="true" /> </behavior> </endpointbehaviors> </behaviors> </system.servicemodel> 2010@FEUP RESTful Services 7 Hosting a REST service The host can be an application or the IIS server In any case the class implementing the host should be WebServiceHost instead of simply ServiceHost Example: A console application host class RestHost { static void Main() { WebServiceHost host = new WebServiceHost( typeof(restservice) ); host.open(); Console.WriteLine("Rest service running"); Console.WriteLine("Press ENTER to stop the service"); Console.ReadLine(); host.close(); 2010@FEUP RESTful Services 8

A client for a REST service The client can use a proxy or generate the request directly This kind of service doesn t generate a description and because of that we can not build a proxy automatically But it is simple to write one: class RestProxy : ClientBase<IRestService>, IRestService { public Users GetUsers() { return Channel.GetUsers(); public User GetUser(string id) { return Channel.GetUser(id); public void DeleteUser(string id) { Channel.DeleteUser(id); 2010@FEUP RESTful Services 9 REST service operation GET methods can be invoked in a browser Also the host can generate a help page 2010@FEUP RESTful Services 10

REST services in Java A standard specification for REST services (JAX-RS) is included in the specification Java EE 6 The Jersey library is the reference implementation of JAX-RS It s included in the Glassfish application server The NetBeans IDE supports developing REST services with Jersey A REST service is a POJO with a number of annotations specifying URIs, parameters, representations, operation verbs In NetBeans is seen as a Web Application resource REST services should be application stateless (no sessions), but not the resource they interact with They can use other server resources (EJBs, Entities, ) through dependency injection 2010@FEUP RESTful Services 11 Using NetBeans to create a REST service Create a Web Application in Glassfish 3 You can use the web page to give some presentation and help about the service Add a new resource to the web application specifying a RESTful Web Service from patterns and a Simple Root Resource 2010@FEUP RESTful Services 12

REST service specification Specify the service inside the Web application You need a class for the operations (the service) Probably you will need also a class to represent the resource that the service will access 2010@FEUP RESTful Services 13 REST annotations The class implementing the service (containing the operations as methods) must be annotated with @Path(<base address>) The <base address> is a string specifying the base path to the resource represented by the service. This path is appended to the web application address + REST Resource (specified when we added the service to the web application) @Path( users") public class UsersResource { // service methods The classes representing the resource or its Components and appearing as a parameter Or as a result of an operation (therefore transferred Between clients and service) must be annotated With @XmlRootElement @XmlRootElement public class User { public int Id; public String Name; public User() { public User(int id, String name) { Id = id; Name = name; 2010@FEUP RESTful Services 14

Methods annotations Service methods should be annotated with the http operation verb: @GET, @POST, @PUT, @DELETE or @HEAD Also each method can have an additional path specification to add to the class path. This specification can include a template (between { ) Post and Put operations can have a payload: The format of that payload can be specified in a @Consumes(<format>) annotation and is assigned to a parameter of the service. All operations can produce a result also encoded in a specified format in @Produces(<format>) annotation Other parameters for the methods can be obtained from the path (@PathParam(<template>) annotation), from a parameter in the URI (appended like?name=value) (@QueryParam(<name>) annotation) or from a cookie (@CookieParam(<name>) annotation) @Path("users") public class UsersResource { @GET @Produces("application/json") public ArrayList<User> getusers() { @GET @Path("{id") @Produces("application/json") public User getuser(@pathparam("id") String id) { @POST @Consumes("text/plain") public Response adduser(string name) { @DELETE @Path("{id") public void deleteuser(@pathparam("id") String id) { 2010@FEUP RESTful Services 15 Data formats and state The most common supported formats that can be specified in the @Produces and @Consumes annotations include the following MIME types: - application/xml - application/json - text/plain - text/html - text/xml -image/* We can use other resources in our REST service, like EJBs, including singletons. JAX-RS and the Jersey library support the resource injection available in Java EE 6 application servers //Stateful resource (singleton) @Singleton public class UsersStorage { @Stateless // needed for dependency injection @Path("users") public class UsersResource { @Context // from the context call private UriInfo uriinfo; @EJB // the singleton EJB private UsersStorage listofusers;. 2010@FEUP RESTful Services 16