Service Oriented Computing: Web Service Development. Dr. Cristian Mateos Diaz (http://users.exa.unicen.edu.ar/~cmateos/cos) ISISTAN - CONICET

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

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

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

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

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

WEB SERVICES. Revised 9/29/2015

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

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

Developing Java Web Services

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

Module 13 Implementing Java EE Web Services with JAX-WS

ActiveVOS Server Architecture. March 2009

Web Services ( )

Web Service Development Using CXF. - Praveen Kumar Jayaram

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

e-gov Architecture Service Interface Guidelines

JVA-561. Developing SOAP Web Services in Java

Java Web Services Training

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

Oracle Service Bus. User Guide 10g Release 3 Maintenance Pack 1 (10.3.1) June 2009

Web Services and their support in Java

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

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

JAX-WS Developer's Guide

Motivation Definitions EAI Architectures Elements Integration Technologies. Part I. EAI: Foundations, Concepts, and Architectures

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

Reusing Existing * Java EE Applications from Oracle SOA Suite

A standards-based approach to application integration

Developing Web Services with Eclipse

Introduction to Web services for RPG developers

Web Services Technologies Examples from the Mainstream

T320 E-business technologies: foundations and practice

Assessing the usefulness of the WS-I tools for interoperability testing

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

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

Brekeke PBX Web Service

Internationalization and Web Services

The Service Revolution software engineering without programming languages

Developing Web Services with Apache CXF and Axis2

Chapter 1: Web Services Testing and soapui

An Oracle White Paper November Oracle Primavera P6 EPPM Integrations with Web Services and Events

02267: Software Development of Web Services

Web Services. Distributed Object Systems 11. Web Services, SOAP and NET. Web Applications. Web Services. Web services vs Distributed Objects

NetBeans IDE Field Guide

How To Run A Soap Message In Java (Soap) On A Microsoft Powerbook (Soapy) On Your Computer Or Microsoft.Net (Soaps) On An Ipad Or Ipad (So

Lesson 4 Web Service Interface Definition (Part I)

Web Service Testing. SOAP-based Web Services. Software Quality Assurance Telerik Software Academy

Designing an Enterprise Application Framework for Service-Oriented Architecture 1

SOA Patterns and Best Practices

Service-Oriented Architectures

Copyright. Restricted Rights Legend. Trademarks or Service Marks. Copyright 2003 BEA Systems, Inc. All Rights Reserved.

Connecting Custom Services to the YAWL Engine. Beta 7 Release

Distributed Embedded Systems

Developing Web Services Applications

Web Services in Oracle Fusion Middleware. Raghu Kodali Consulting Product Manager & SOA Evangelist Oracle Fusion Middleware Oracle USA

Overview of Web Services API

IBM SPSS Collaboration and Deployment Services Version 6 Release 0. Single Sign-On Services Developer's Guide

Oracle Application Server 10g Web Services Frequently Asked Questions Oct, 2006

Accessing Data with ADOBE FLEX 4.6

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

How To Develop A Web Service In A Microsoft J2Ee (Java) 2.5 (Oracle) 2-Year Old (Orcient) 2Dj (Oracles) 2E (Orca) 2Gj (J

Middleware and the Internet. Example: Shopping Service. What could be possible? Service Oriented Architecture

1 What Are Web Services?

Building Web Services with Apache Axis2

1 What Are Web Services?

Types of Cloud Computing

JAVA API FOR XML WEB SERVICES (JAX-WS)

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

Web Services Development In a Java Environment

Introduction to Oracle WebLogic. Presented by: Fatna Belqasmi, PhD, Researcher at Ericsson

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

Web services (WS) Outline. Intro on Middleware SOAP, HTTP binding WSDL UDDI Development tools References

CHAPTER 10: WEB SERVICES

Mobility Information Series

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

How To Create A C++ Web Service

WIRIS quizzes web services Getting started with PHP and Java

Web services can convert your existing applications into web applications.

Business Process Execution Language for Web Services

Lesson 18 Web Services and. Service Oriented Architectures

Service Oriented Architectures

Challenges and Opportunities for formal specifications in Service Oriented Architectures

Ambientes de Desenvolvimento Avançados

Creating Web Services in NetBeans

Building and Using Web Services With JDeveloper 11g

Oracle WebLogic Server

Hello World RESTful web service tutorial

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

Outline SOA. Properties of SOA. Service 2/19/2016. Definitions. Comparison of component technologies. Definitions Component technologies

Writing Grid Service Using GT3 Core. Dec, Abstract

Building Web Services with XML Service Utility Library (XSUL)

CST6445: Web Services Development with Java and XML Lesson 1 Introduction To Web Services Skilltop Technology Limited. All rights reserved.

Java Programming. JDBC Spring Framework Web Services

an open source web service toolkit for Java Mark Volkmann Object Computing, Inc.

Digital Signature Web Service Interface

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

Consuming, Providing & Publishing WS

ESB Versus ActiveVOS

Developing Google Android Mobile Clients for Web Services: a Case Study

Transcription:

Service Oriented Computing: Web Service Development Dr. Cristian Mateos Diaz (http://users.exa.unicen.edu.ar/~cmateos/cos) ISISTAN - CONICET

Talk outline Web Services SOAP, WSDL, UDDI Developing Web Services Eclipse WTP Testing Web Services soapui Consuming and invoking Web Services Advanced WS programming: DI and Spring remoting

Developing Web Services: Two main approaches Contract-first and code-first (also contract-last): Under contract-first, we specify the WSDL for our service and then we provide an implementation (Eclipse WTP, Spring Web Services) Under code-first, it is the other way around (Eclipse WTP) code-first Contract Implementation contract-first Which one should be followed? Well, it depends...

Developing Web Services: Contract-first vs code-first Code-first is said to be more appropriate for beginners (no need to write service specifications) Code-first is convenient and practical (e.g., automatic deployment, short-lived services, etc.) But... Contract-first ensures that contracts will not change too much over time (the code is more likely to change) Contract-first enables for more reusable, rich schema types

Contract-first or code-first? An industry perspective The Spring Source Community:http://www.springsource.org Explicitly discourages code-first because of the Object/Relational impedance mismatch when converting Java objects to XML Loose of accuracy: for example when using xsd:restriction <simpletype name="airportcode"> <restriction base="string"> <pattern value="[a-z][a-z][a-z]"/> </restriction> </simpletype> could not be associated to a plain java.lang.string... Unportable types (e.g., TreeMap) or type ambiguity when invoking services (Date? Calendar?) Another problem is technological details sneaking in service specifications (e.g., binding-related classes)

Contract-first or code-first? An academic perspective The Daios Project: http://www.infosys.tuwien.ac.at/staff/rosenberg/papers/ic09-daios.pdf Daios adopts a document-oriented approach to service development: it sticks to native XSD types and a complex API type

Contract-first or code-first? An academic perspective (cont.) // Create a Daios backend and preprocess/bind to the service ServiceFrontendFactory factory = ServiceFrontendFactory.getFactory( at.ac.tuwien.infosys.dsg.daiosplugins. + nativeinvoker.nativeserviceinvokerfactory ); ServiceFrontend frontend = factory.createfrontend(new URL( http://vitalab.tuwien.ac.at/ + orderservice?wsdl )); // construct input that we want to pass to the service DaiosInputMessage registration = new DaiosInputMessage(); DaiosMessage address = new DaiosMessage(); address.setstring( City, Vienna ); address.setstring( Street, Argentinierstrasse ); address.setint( Door, 8); registration.setcomplex( Address, address); registration.setstring( First_Name, Philipp ); registration.setstring( Last_Name, Leitner ); // dynamic invocation and retrieve result DaiosOutputMessage response = frontend.requestresponse(registration); String regnr = response.getstring( registrationnr ); //...

Contract-first or code-first: Is there something in between? An example: relax-ws (https://github.com/dlukyanov/relax-ws) A more lightweight contract-first approach Focuses on simplifying WSDL specification/generation # This is "hello world" in relax-ws. service Hello { port { operation SayHello { in { element name {xsd:string out { element message {xsd:string

Developing Web Services: Summary (so far) Contract-first vs code-first (a.k.a. Contract-last) Plus intermediate approaches Operation oriented versus document oriented... Aren't these already considered in the specifications? Yes!

Developing Web Services: Binding styles There are several ways of binding to WSDL-described SOAP services: WSDL binding style? RPC; SOAP style? Document; SOAP style? encoded literal encoded literal RPC/encoded RPC/literal document/encoded document/literal... plus another style known as Document/literal wrapped RPC and Document merely dictate how to translate a WSDL binding to a SOAP message... the terminology is indeed unfortunate! Encoded and Literal make a lot more sense :)

Developing Web Services: Binding styles (cont.) <wsdl:definitions... > <wsdl:binding name="foosoapbinding" type="..."> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc document"?/> <wsdl:operation name="mymethod"> <wsdl:input name="mymethodrequest"> <soap:body use="encoded literal"?/> </wsdl:input> <wsdl:output name="mymethodresponse"> <soap:body use="encoded literal"?/> </wsdl:output> </wsdl:operation> </wsdl:binding> </wsdl:definitions> style= rpc : Input is a service name plus a number of arguments style= document : Input is any XML document use= literal versus encoded : whether the body of SOAP messages conform to a specific schema or not

Developing Web Services: Binding styles (cont.) Client Web Container Web Service 1. Request WSDL [WSDL document] 2. Invoke service 3. Validate input 4. Dispatch call...

WSDL Example: A service for adding two numbers (rpc/encoded) public int add(int number1, int number 2) <message name="addrequest"> <part name="number1" type="xsd:int"/> <part name="number2" type="xsd:int"/> </message> <message name="addresponse"> <part name="return" type="xsd:int"/> </message> <porttype name="addporttype"> <operation name="add" parameterorder="number1 number2"> <input message="tns:addrequest"/> <output message="tns:addresponse"/> </operation> </porttype> Pros: Simplicity, dispatching time Cons: Overhead, Validation, WS-I compliance SOAP <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:add> <number1 xsi:type="xsd:int">1</number1> <number2 xsi:type="xsd:int">2</number2> </ns0:add> </env:body> <env:envelope> <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:addresponse> <return xsi:type="xsd:int">3</return> </ns0:addresponse> </env:body> <env:envelope>

Example: A service for adding two numbers (rpc/literal) WSDL <message name="addrequest"> <part name="number1" type="xsd:int"/> <part name="number2" type="xsd:int"/> </message> <message name="addresponse"> <part name="return" type="xsd:int"/> </message> <porttype name="addporttype"> <operation name="add" parameterorder="number1 number2"> <input message="tns:addrequest"/> <output message="tns:addresponse"/> </operation> </porttype> Pros: Simplicity, dispatching time, WS-I compliance Cons:Validation SOAP <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:add> <number1>1</number1> <number2>2</number2> </ns0:add> </env:body> <env:envelope> <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:addresponse> <return>3</return> </ns0:addresponse> </env:body> <env:envelope>

Example: A service for adding two numbers (document/literal) WSDL <types> <schema targetnamespace="our namespace"...> <element name="request"> <xsd:complextype> <sequence> <element name="number1" type="xsd:int"/> <element name="number2" type="xsd:int"/> </sequence> </xsd:complextype> </element> <element name="response"> <xsd:complextype> <xsd:sequence> <element name="result" type="xsd:int"/> </xsd:sequence> </xsd:complextype> </element> </schema> </types> <message name="request"> <part name="param" element="ns0:request"/> </message> <message name="response"> <part name="return" element="ns0:response"/> </message> SOAP <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:request> <number1>1</number1> <number2>2</number2> </ns0:request> </env:body> <env:envelope> <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:response> <result>3</result> </ns0:response> </env:body> <env:envelope> Pros: Validation, WS-I compliance Cons: Complexity, Performance (Operation name is absent)

Example: A service for adding two numbers (doc/lit. wrapped) WSDL <types> <schema targetnamespace="our namespace"...> <element name="add"><!-- named after the operation--> <xsd:complextype> <sequence> <element name="number1" type="xsd:int"/> <element name="number2" type="xsd:int"/> </sequence> </xsd:complextype> </element> <element name="addrestype"> <xsd:complextype> <xsd:sequence> <element name="result" type="xsd:int"/> </xsd:sequence> </xsd:complextype> </element> </schema> </types> <message name="addrequest"> <part name="param" element="ns0:add"/> </message> <message name="addresponse"> <part name="return" element="ns0:addrestype"/> </message> SOAP <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:add> <number1>1</number1> <number2>2</number2> </ns0:add> </env:body> <env:envelope> <env:envelope... xmlns:ns0="our namespace"> <env:body> <ns0:addresponse> <return>3</return> </ns0:addresponse> </env:body> <env:envelope> Pros: Dispatching time, Validation WS-I compliance Cons: Complexity, Performance, Overloading

Developing Web Services: Available tools Eclipse WTP (Web Tools Platform) - http://www.eclipse.org/webtools - Allows users to create/publish Web Services (code/contract-first) Apache CXF - http://cxf.apache.org - Up-to-date framework that supports many Web Service standards soapui - http://www.soapui.org - Comprehensive tool for testing Web Services - Integration with tcpmon WS-I interoperability testing tools - http://www.ws-i.org/deliverables/workinggroup.aspx?wg=testingtools - Implementations available for Java and C#

Developing Web Services: Axis tcpmon

Talk outline Web Services SOAP, WSDL, UDDI Developing Web Services Eclipse WTP Testing Web Services soapui Consuming and invoking Web Services

Testing Web Services In a broad sense, testing is the process of checking whether a piece of software does what it is supposed to do When dealing with WSDL-based Web Services, it implies: Not only test whether a service is listening Checking XSD compliance Checking input-output correspondence (black-box testing) Indeed, the same issues that arise when testing traditional software also apply (e.g., coverage)

Testing Web Services: soapui soapui (http://www.soapui.org) is a comprehensive tool for testing Web Services It supports: Functional testing supporting all the testing aspects mentioned earlier Load testing (load testing itself, stress testing, soak testing, scalability testing)

Testing Web Services: soapui (cont.)

Testing Web Services: soapui (cont.) A lot of more assertions can be defined by using XML-based query languages (XPath and XQuery), WS-I, and so on...

Testing Web Services: soapui (cont.) In traditional Web development, coverage is used to measure how much of the actual code base that is being exercised during a given execution scenario soapui computes coverage based on two separate aspects, i.e. message coverage and assertion coverage

Talk outline Web Services SOAP, WSDL, UDDI Developing Web Services Eclipse WTP Testing Web Services soapui Consuming and invoking Web Services Advanced WS programming: DI and Spring remoting

Consuming Web Services Does the application code directly use the binding protocol to talk to a service? Yes (e.g., it is possible to call via APIs services exposed through RMI, HTTP, IIOP, JMS... or even SOAP) - e.g., Axis No, then does the application code indirectly uses the binding protocol to talk to a service? No or aiming to - e.g., CXF, WSIF - WSDL = service descriptor Yes - e.g., Spring WS, Spring remoting - WSDL ignored or partially exploited

RMI in a nutshell

Consuming Web Services: Apache Axis import org.apache.axis.client.*; import javax.xml.namespace.qname; public class TestClient { public static void main(string [] args) { try { String endpoint = "http://ws.apache.org:5049/axis/services/echo"; Service service = new Service(); Call call = (Call) service.createcall(); call.settargetendpointaddress( new java.net.url(endpoint) ); call.setoperationname(new QName("http://soapinterop.org/", "echostring")); String ret = (String) call.invoke( new Object[] { "Hello!" ); System.out.println("Sent 'Hello!', got '" + ret + "'"); catch (Exception e) { System.err.println(e.toString());

Consuming Web Services: Axis 2 (http://axis.apache.org/axis2/java/core/) import org.apache.axis2.simpleservicestub.echorequest; import org.apache.axis2.simpleservicestub.echoresponse; public class TestClient { public static void main(string[] args) throws Exception { SimpleServiceStub stub = new SimpleServiceStub(); //Create the request EchoRequest request = new SimpleServiceStub.EchoRequest(); request.setparam0("hello world"); //Invoke the service EchoResponse response = stub.echo(request); System.out.println(response.get_return()); WSDL2Java.sh -uri http://localhost:8080/axis2/services/simpleservice?wsdl -o /path/to/my/client/code/

Consuming Web Services: WSIF (http://ws.apache.org/wsif) import org.apache.wsif.*; import org.apache.wsif.wsifservicefactory; import org.apache.wsif.wsifexception; import java.rmi.remoteexception; import simplesoap.client.stub.com.themindelectric.www.netxmethodsservicesstockquotestockquotep orttype; // Pregenerated stub interface public class TestClient { public static void main(string[] args) throws WSIFException {... // create a service factory WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); WSIFService service = factory.getservice(wsdllocation, null, null, "http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.stockquote/", "net.xmethods.services.stockquote.stockquoteporttype"); // create the stub NetXmethodsServicesStockquoteStockQuotePortType stub = (NetXmethodsServicesStockquoteStockQuotePortType) service.getstub( NetXmethodsServicesStockquoteStockQuotePortType.class); System.out.println(stub.getQuote(symbol)); // do the invocation

Proxying Web Services Explicitly (e.g., Axis2, WSIF) How are proxies manipulated/ instantiated? Implicitly (e.g., CXF, Spring remoting) - Based on AOP and reflection Adapters (more on this latter) Stubless (e.g., Spring Web Services)

Asynchronous Web Services So far, we have dealt with synchronous clients Many invocation frameworks support the notion of asynchronous Web Service call Similar to the Notification WSDL operation pattern E.g., CXF supports: Polling approach: The service returns a special response object (Future) that can be polled to check whether or not a response message has arrived Callback approach: Developers call another special method that takes a reference to a callback object. The framework calls back on this object to pass it on the contents of the response message

Asynchronous Web Services: Java Futures From version 5.0 on, Java has support for special objects called futures provided by the java.lang.concurrent package class interface ArchiveSearcher { String search(string target); public class App { ExecutorService executor =... ArchiveSearcher searcher =... void showsearch(final String target) throws InterruptedException { Future<String> future = executor.submit(new Callable<String>() { public String call() { return searcher.search(target); ); displayotherthings(); // do other things while searching try { displaytext(future.get()); // use future catch (ExecutionException ex) { cleanup(); return;

Asynchronous Web Services: Proxy generation <wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" name="helloworld"...> <wsdl:types> <schema targetnamespace="http://apache.org/hello_world_async_soap_http/types" xmlns="http://www.w3.org/2001/xmlschema" xmlns:x1="http://apache.org/hello_world_async_soap_http/types" elementformdefault="qualified"> <element name="greetmesometime"> <complextype> <sequence><element name="requesttype" type="xsd:string"/></sequence> </complextype> </element> <element name="greetmesometimeresponse"> <complextype> <sequence><element name="responsetype" type="xsd:string"/></sequence> </complextype> </element> </schema> </wsdl:types> <wsdl:message name="greetmesometimerequest"> <wsdl:part name="in" element="x1:greetmesometime"/> </wsdl:message> <wsdl:message name="greetmesometimeresponse"> <wsdl:part name="out" element="x1:greetmesometimeresponse"/> </wsdl:message> <wsdl:porttype name="greeterasync"> <wsdl:operation name="greetmesometime"> <wsdl:input name="greetmesometimerequest" message="tns:greetmesometimerequest"/> <wsdl:output name="greetmesometimeresponse" message="tns:greetmesometimeresponse"/> </wsdl:operation> </wsdl:porttype>... </wsdl:definitions>

Asynchronous Web Services: Proxy generation (cont.) After running wsdl2java, we obtain the following client-side interface code: /* Generated by WSDLToJava Compiler. */ package org.apache.hello_world_async_soap_http;... import java.util.concurrent.future; import javax.xml.ws.asynchandler; import javax.xml.ws.response;... public interface GreeterAsync { public Future<?> greetmesometimeasync( java.lang.string requesttype, AsyncHandler<org.apache.hello_world_async_soap_http.types.GreetMeSometimeResponse> asynchandler); public Response<org.pache.hello_world_async_soap_http.types.GreetMeSometimeResponse> greetmesometimeasync(java.lang.string requesttype); public java.lang.string greetmesometime(java.lang.string requesttype);

Asynchronous Web Services: Polling-based invocation Non-blocking polling Response<GreetMeSometimeResponse> greetmesometimeresp =...; if (greetmesometimeresp.isdone()) { GreetMeSometimeResponse reply = greetmesometimeresp.get(); Blocking polling Response<GreetMeSometimeResponse> greetmesometimeresp =...; GreetMeSometimeResponse reply = greetmesometimeresp.get(60l, java.util.concurrent.timeunit.seconds);

Asynchronous Web Services: Callback-based invocation package demo.hw.client; import javax.xml.ws.asynchandler; import javax.xml.ws.response; import org.apache.hello_world_async_soap_http.types.greetmesometimeresponse; public class TestAsyncHandler implements AsyncHandler<GreetMeSometimeResponse> { private GreetMeSometimeResponse reply; public void handleresponse(response<greetmesometimeresponse> response) { try { reply = response.get(); catch (Exception ex) { ex.printstacktrace(); public String getresponse() { return reply.getresponsetype(); Our callback or handler just obtains and stores the result in a variable...

Asynchronous Web Services: Callback-based invocation (cont.) public static void main(string args[]) throws Exception {... TestAsyncHandler testasynchandler = new TestAsyncHandler(); Future<?> response = port.greetmesometimeasync( "Homer Simpson", testasynchandler); while (!response.isdone()) { Thread.sleep(100); resp = testasynchandler.getresponse();... System.exit(0); Note that results are only made accessible to the handler...