XML in Programming 2, Web services



Similar documents
Modern XML applications

"Modern" XML applications

"Modern" XML applications

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

Java Web Services Training

Developing Java Web Services

4. Concepts and Technologies for B2C, B2E, and B2B Transaction

JVA-561. Developing SOAP Web Services in Java

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

WEB SERVICES. Revised 9/29/2015

Introduction into Web Services (WS)

Web Services Technologies

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

XIII. Service Oriented Computing. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

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

Middleware and the Internet

Creating Web Services in NetBeans

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

VALLIAMMAI ENGINEERING COLLEGE SRM NAGAR, KATTANKULATHUR DEPARTMENT OF COMPUTER APPLICATIONS SUBJECT : MC7502 SERVICE ORIENTED ARCHITECTURE

DataDirect XQuery Technical Overview

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

ISM/ISC Middleware Module

Principles and Foundations of Web Services: An Holistic View (Technologies, Business Drivers, Models, Architectures and Standards)

B2B Glossary of Terms

What is a Web service?

Web-Service Example. Service Oriented Architecture

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

How To Understand A Services-Oriented Architecture

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

Web Services Development In a Java Environment

Introduction to WebSphere Process Server and WebSphere Enterprise Service Bus

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

High Performance XML Data Retrieval

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

Introduction to Web Services

Developing Web Services Applications

Introduction. Tom Dinkelaker, Ericsson Guido Salvaneschi, Mira Mezini, TUD

Web Services Advanced Topics

EAI OVERVIEW OF ENTERPRISE APPLICATION INTEGRATION CONCEPTS AND ARCHITECTURES. Enterprise Application Integration. Peter R. Egli INDIGOO.

What is Distributed Annotation System?

NetBeans IDE Field Guide

Research on the Model of Enterprise Application Integration with Web Services

SCA-based Enterprise Service Bus WebSphere ESB

1.264 Lecture 24. Service Oriented Architecture Electronic Data Interchange (EDI) Next class: Anderson chapter 1, 2. Exercise due before class

MD Link Integration MDI Solutions Limited

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

A standards-based approach to application integration

Distributed systems. Distributed Systems Architectures

Agents and Web Services

Introduction to Service Oriented Architectures (SOA)

A Signing Proxy for Web Services Security. Dr. Ingo Melzer RIC/ED

Web Services Middleware Application: A Solution for SMEs towards B2B Framework Implementation

Redbook Overview Patterns: SOA Design with WebSphere Message Broker and WebSphere ESB

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

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

Ontology-based Web Service Composition: Part 1. Rolland Brunec Betreuerin: Sabine Maßmann Universität Leipzig, Abteilung Datenbanken

XML Processing and Web Services. Chapter 17

Internationalization and Web Services

Service Oriented Architecture

Improving performance for security enabled web services. - Dr. Colm Ó héigeartaigh

Griglie e Sistemi di Elaborazione Ubiqui

Lesson 4 Web Service Interface Definition (Part I)

Service-Oriented Architecture and its Implications for Software Life Cycle Activities

rpafi/jl open source Apache Axis2 Web Services 2nd Edition using Apache Axis2 Deepal Jayasinghe Create secure, reliable, and easy-to-use web services

BBM467 Data Intensive ApplicaAons

Service Oriented Architecture using JAVA

AquaLogic Service Bus

Introduction to UDDI: Important Features and Functional Concepts

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

Cloud Computing & Service Oriented Architecture An Overview

24 BETTER SOFTWARE MARCH

4.2 Understand Microsoft ASP.NET Web Application Development

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

Mobile devices as Web service providers

A PERFORMANCE MODEL WEB SERVICE

Web-Services Testing Tools

Integration of Hotel Property Management Systems (HPMS) with Global Internet Reservation Systems

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

Java Security Web Services Security (Overview) Lecture 9

Run-time Service Oriented Architecture (SOA) V 0.1

Oracle SOA Reference Architecture

Introduction to Testing Webservices

SOAP Overview. Tamas Szigyarto

REST vs. SOAP: Making the Right Architectural Decision

Business Process Execution Language for Web Services

Service-Oriented Architecture (SOA) vs. Component Based Architecture. Helmut Petritsch

Leveraging Service Oriented Architecture (SOA) to integrate Oracle Applications with SalesForce.com

e-gov Architecture Service Interface Guidelines

Web Services Strategy

Getting Started with Service- Oriented Architecture (SOA) Terminology

Developing Web Services with Eclipse

XML- New meta language in e-business

Open ESB. Sang Shin Java Technology Evangelist Sun Microsystems, Inc. Raffaele Spazzoli Imola Informatica 1

BUSINESS PROCESS AND EBXML - WEB SERVICES INTEGRATION PLATFORM, REQUIREMENTS, ARCHITECTURES, SECURITY

Web Services Technologies: State of the Art

SOA Planning Guide The Value Enablement Group, LLC. All rights reserved.

Web Services. Seminar on Semantic Web & Web Services. - W3C Finland - 6th May Suresh Chande,

Web Services and Service Oriented Architectures. Thomas Soddemann, RZG

Web Services Overview. Ajith Abraham

HexaCorp. White Paper. SOA with.net. Ser vice O rient ed Ar c hit ecture

Transcription:

XML in Programming 2, Web services Patryk Czarnik XML and Applications 2013/2014 Lecture 5 4.11.2013

Features of JAXP 3 models of XML documents in Java: DOM, SAX, StAX Formally JAXB is a separate specification Reading and writing documents Transformations of XML documents (Transformers) applying XSLT in our programs translating internal form of representation XPath support Validation against DTD (only during parsing) against XML Schema (during parsing or using Validators) against XML Schema 1.1, Relax NG, or other alternative standards when implementation supports 2 / 37

Transformer: source and result Source Transformer Result StreamSource StreamResult DOMSource DOMResult JAXBSource JAXBResult SAXSource SAXResult StAXSource StAXResult SAAJResult 3 / 37

Applications of Transformers Simple: invoking XSLT transformations from Java changing internal representation of XML in our program Tricky: parsing and writing documents, e.g. serialisation of a DOM tree serialisation of modified (or generated) sequences of SAX events (together with SAX filters) enabling on-the-fly processing of large XML documents 4 / 37

Editing XML documents More natural when whole document present in memory DOM generic API JAXB deep embedding of XML in application model Harder, but possible, using node-by-node processing required when processing big documents within small amount of memory suggested for big ( long and flat ) documents and simple local operations then we can save substantial resources StAX possible using writers IMO XMLEventWriter more convenient than XMLStreamWriter SAX no direct support for editing/writing available indirect solution: SAX filters and Transformer 5 / 37

Editing XML documents examples 6 / 37

Validation Against DTD setvalidating(true) before parsing Against XML Schema (or other schema formats, if implementation supports) setschema(schema) before parsing using Validator Validator API validate(source) only checking of correctness validate(source, Result) augmented document returned not possible to use as Transformer source and result must be of the same kind (my private observation) not always working as expected 7 / 37

Handling errors Most JAXP components (specifically SAX and DOM parsers, Validators) may throw SAXException signal errors through ErrorHandler events Interface ErrorHandler 3 methods (and severity levels): warning, error, fatalerror registering with seterrorhandler allows to override default error handling Required to manually handle validation errors 8 / 37

Validation examples 9 / 37

XPath support in Java DOM XPath module implementation org.w3c.dom.xpath officially not a part of Java SE, but available in practice (by inclusion of Xerces in Oracle Java SE runtime) JAXP XPath API javax.xml.xpath most efficient when applied for documents in memory (DOM trees) our examples show this solution Note: using XPath may significantly reduce developer's work, but the application may be less efficient (than if we used SAX, for example) 10 / 37

Electronic data interchange (EDI) motivation How to interchange data between companies / institutions (B2B)? paper electronic data interchange How to establish EDI protocol? customer receives (or buys) a tool from provider smaller partner complies to bigger parter ad-hoc created conversion tools standard Standard deployment levels software developed according to standard from beginning interface added to legacy system 11 / 37

Pre-XML solutions ANSI Accredited Standards Committee X12 sub-group USA national standard used mainly in America EDIFACT international standard (UN/CEFACT and ISO) used mainly in Europe and Asia 12 / 37

EDIFACT characteristic Format text hardly readable tree structure Predefined dictionaries 193 message types 279 segments 186 elements (counted for version 08a, 2008) 13 / 37

EDIFACT EDIFACT message example UNB+IATB:1+6XPPC+LHPPC+940101:0950+1' UNH+1+PAORES:93:1:IA' MSG+1:45' IFT+3+XYZCOMPANY AVAILABILITY' ERC+A7V:1:AMD' IFT+3+NO MORE FLIGHTS' ODI' TVL+240493:1000::1220+FRA+JFK+DL+400+C' PDI++C:3+Y::3+F::1' APD+74C:0:::6++++++6X' TVL+240493:1740::2030+JFK+MIA+DL+081+C' PDI++C:4' APD+EM2:0:1630::6+++++++DA' UNT+13+1' UNZ+1+1' 14 / 37

EDIFACT structure Wymiana interchange ( ) Wiadomość message ( ) Grupa segment ( group ) Segment Złożenie composite ( ) Element data ( element ) MEA+WT+AAD+KGM:690+X5 ' + KGM:690 + : 690 15 / 37

XML EDI Idea: use XML as data format for EDI Traditional EDI Documents unreadable without specification Compact messages Centralised standard maintenance Changes in format requires software change Specialised tools needed XML EDI Self-descriptioning documents format Verbose messages Pluggable, flexible standards Well written software ready to extensions of format XML-format layer handled by general XML libraries 16 / 37

XML EDI flexibility Format flexibility Structures: choosing, repeating, nesting, optionality Format extensions and mixing via namespaces Applications Data interchange between partners' systems Web interface (with little help from XSLT) Web Services integration 17 / 37

XML EDI standardisation Framework level general rules for all kinds of data data of the same kind should be represented in the same way (not to define the same twice) example: Electronic Business XML (ebxml). Industry standards (examples) banking trade and logistic Automotive Industry Action Group motor industry (mainly American) Health Level Seven health care Open Travel Alliance (people) transport and tourist services 18 / 37

XML for application integration Goal data interchange between applications applications/modules/components with different internal formats XML as interface Usage: client/server communication nodes of distributed systems components integration remote configuration and monitoring of applications 19 / 37

Local and global applications Local integration within single project or related projects of a single owner communication between components possibly in distributed architecture ad-hoc solutions for given problems possibility of using standard Global integration services available in Internet for any party different parts cooperation standardisation required motivation to use Web Services 20 / 37

Web Services Idea: a website for programs (instead of people) General definition communication based on high-level protocols structural messages services described searching services Concrete definition: Classical Web-Services HTTP or other protocols SOAP WSDL UDDI 21 / 37

Web Services typical applications Providing data (for free or paid) timetables weather stock and currency notes Services searching software updates Business operation between partners booking tickets or hotel rooms ordering (and tracing order status) electronic data interchange e-administration 22 / 37

Web Services standardisation SOAP (initially Simple Object Access Protocol: beginnings: 1998 v1.1: W3C Note, 2001 (still in use) v1.2: W3C Recommendation, June 2003 (also used) Web Services Description Language: W3C Note, 2001 (most applications use this version!) v2.0: W3C Recommendation, June 2007 Universal Description Discovery and Integration: OASIS project 23 / 37

Web Services standardisation (2) Web Services Interoperability levels of WS compliance: WS-I Basic Profile, Simple Soap Binding Profile,... WS-* standards: various standards, usually not W3C: WS-Eventing, WS-Addressing, WS-Routing, WS-Security Business Process Execution Language (OASIS) WS semantics description, programming using WS as building blocks 24 / 37

SOAP communication protocol Built on top of existing transport protocol (HTTP or other) Message format main message part XML envelope and some special elements defined in standard implementation-dependent content additional attachments in any format (even binary) Differences to RPC, CORBA, DCOM etc.: data represented in extensible, structural format (XML) data types independent of platform (XML Schema) lower efficiency 25 / 37

SOAP message general form 26 / 37

SOAP 1.2 message <soap:envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingstyle="http://www.w3.org/2001/12/literal"> <soap:header> <t:trans xmlns:t="http://www.w3schools.com/transaction/" soap:mustunderstand="1">234</m:trans> </soap:header> <soap:body> <m:getprice xmlns:m="http://www.w3schools.com/prices"> <m:item>apples</m:item> <m:currency>pln</m:currency> </m:getprice> </soap:body> </soap:envelope> 27 / 37

SOAP 1.2 normal response <soap:envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingstyle="http://www.w3.org/2001/12/soap-encoding"> <soap:body> <m:getpriceresponse xmlns:m="http://www.w3schools.com/prices"> <m:price>1.90</m:price> <m:currency>pln</m:currency> </m:getpriceresponse> </soap:body> </soap:envelope> 28 / 37

SOAP 1.2 fault response <soap:envelope xmlns:usos="urn:usos" xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingstyle="http://www.w3.org/2001/12/soap-encoding"> <soap:body> <soap:fault> <soap:faultcode>soap:receiver</soap:faultcode> <soap:faultstring>data missing</soap:faultstring> <soap:faultdetail> <usos:exception>found no student identified with <usos:ind>123</usos:ind> </usos:exception> </soap:faultdetail> </soap:fault> </soap:body> </soap:envelope> 29 / 37

SOAP more info Request and response have the same structure. In fact, we can think of SOAP as a document transport protocol, not necessarily in client-server architecture. Header part optional, Body part required. Restrictions on XML part: no DTD (and external entity references), no processing instructions. Although SOAP allows many body elements (elements within soap:body), WS-I BP requires exactly one. To make applications portable we should follow this restriction. 30 / 37

WSDL service description XML document describing a service Interface ( visit card ) of a service (or set of services) Specifies (from abstract to concrete things) XML types and elements (using XML Schema) types of messages port types available operations, their input and output details of binding abstract operations to a concrete protocol (SOAP in case of classical services) ports concrete instances of services, with their URL Splitting definitions into several files and using external schema definitions available 31 / 37

WSDL 1.1 structure <?xml version="1.0" encoding="utf-8"?> <definitions name='helloworldservice' targetnamespace='http://example.com/hello' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://example.com/hello' xmlns:xsd='http://www.w3.org/2001/xmlschema'> <types>... </types> <message name='helloworld_sayhello'>... </message> <message name='helloworld_sayhelloresponse'>... </message> <porttype name='helloworld'>... </porttype> <binding name='helloworldbinding' type='tns:helloworld'>... </binding> <service name='helloworldservice'> <port binding='tns:helloworldbinding' name='helloworldmyport'>... </port> </service> </definitions> Elementy i typy XMLSchema Komunikaty parametry wejściowe i rezultat Interfejs określający udostępniane operacje Wiązanie z konkretnym protokołem Definicja usługi sieciowej 32 / 37

WSDL and SOAP interaction Basically specified through binding element in WSDL not so simple, because of many possibilities RPC style SOAP XML structure derived basing on operation name and message parts Document style theoretically designed to allow sending arbitrary XML documents in practice also used for RPC realisation, but the author of WSDL has to define an appropriate document structure (some tools may be helpful, e.g. bottom-up service generation in Java JAX-WS) Message use: literal or encoded. We should use literal in modern applications. 33 / 37

Service registration and discovery Idea service provider registers service user searches for service and finds it in registry Universal Description Discovery and Integration (UDDI) available as service (SOAP) business category-based directory ( yellow pages ) searching basing on service name, description ( white pages ) registration and updates for service providers 34 / 37

UDDI issues Main issue who can register? anybody chaos and low reliability accepted partners institution responsible for access policy needed, no such (widely accepted) institution exists Reality UDDI rarely used if ever for local SOA-based solutions (intranets) 35 / 37

Service Oriented Architecture Idea services built basing on other services even addition defined as a Web Service :) software split into components and layers with WS interfaces between them precise specification required (interesting research field...) Critique modular, flexible, and scalable solutions by the cost of (sometimes) irrational inefficiency and complexity Use reasonably! 36 / 37

Are Web Services good or bad? Web Service recommended when Many partners or public service (standardisation) Heterogeneous architecture Text and structural data already present in problem domain Interoperability and flexibility more important than efficiency Web Service?... not necessarily Internal, homogeneous solution. Binary and flat data Efficiency more important than interoperability and flexibility 37 / 37