What is in a Distributed Object System? Distributed Object Systems 5 XML-RPC / SOAP. Examples. Problems. HTTP protocol. Evolution



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

1.Remote Procedure Call Basics Requests Types Response Strategies/Goals FAQ...

Middleware and the Internet

ISM/ISC Middleware Module

Types of Cloud Computing

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

WEB SERVICES. Revised 9/29/2015

Web-Programmierung (WPR)

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

What is a Web service?

What is Distributed Annotation System?

Middleware Lou Somers

Call Detail Record Access Service Part No R01

Developing Java Web Services

Unit IV: SOAP protocol, XML-RPC, HTTP, SOAP faults and SOAP attachments, Web services, UDDI, XML security

Web Services Technologies

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

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

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

Web Services Developer s Guide

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

Lesson 4 Web Service Interface Definition (Part I)

Java Web Services Training

Distributed Applications. Python

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

Building Web Services with XML Service Utility Library (XSUL)

JAVA API FOR XML WEB SERVICES (JAX-WS)

gsoap User Guide

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

Web-Service Example. Service Oriented Architecture

Building Web Services with Apache Axis2

JVA-561. Developing SOAP Web Services in Java

SOAP Overview. Tamas Szigyarto

Web Services. Mark Volkmann Partner Object Computing, Inc. What Are Web Services?

Web services can convert your existing applications into web applications.

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

Web Services Development In a Java Environment

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

What is COM/DCOM. Distributed Object Systems 4 COM/DCOM. COM vs Corba 1. COM vs. Corba 2. Multiple inheritance vs multiple interfaces

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

Concept, implementation and performance testing of a mobile Web Service provider for Smart Phones

LabVIEW Internet Toolkit User Guide

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

WWW. World Wide Web Aka The Internet. dr. C. P. J. Koymans. Informatics Institute Universiteit van Amsterdam. November 30, 2007

Infrastructure that supports (distributed) componentbased application development

Developing a Web Service Based Application for Mobile Client

CS 378 Big Data Programming. Lecture 9 Complex Writable Types

REST web services. Representational State Transfer Author: Nemanja Kojic

Introduction into Web Services (WS)

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

Creating Web Services in NetBeans

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

XML Processing and Web Services. Chapter 17

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

How To Create A C++ Web Service

02267: Software Development of Web Services

File Transfer Service (Batch SOAP) User Guide. A Guide to Submitting batches through emedny FTS

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

Web Services in.net (1)

Python. Network. Marcin Młotkowski. 24th April, 2013

CONTRACT MODEL IPONZ DESIGN SERVICE VERSION 2. Author: Foster Moore Date: 20 September 2011 Document Version: 1.7

Introduction to Web Services

10. Java Servelet. Introduction

XML & Databases. Tutorial. 2. Parsing XML. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

Modeling Web Services with UML

e-gov Architecture Service Interface Guidelines

Onset Computer Corporation

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

Creating Form Rendering ASP.NET Applications

Web Service Development Using CXF. - Praveen Kumar Jayaram

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

Module 17. Client-Server Software Development. Version 2 CSE IIT, Kharagpur

Introduction to Testing Webservices

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

VoIP LAB. 陳 懷 恩 博 士 助 理 教 授 兼 所 長 國 立 宜 蘭 大 學 資 訊 工 程 研 究 所 TEL: # 255

02267: Software Development of Web Services

SW : : Introduction to Web Services with IBM Rational Application Developer V6

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

Agents and Web Services

Q Lately I've been hearing a lot about WS-Security. What is it, and how is it different from other security standards?

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

Easy CramBible Lab DEMO ONLY VERSION Test284,IBM WbS.DataPower SOA Appliances, Firmware V3.6.0

Lehrstuhl für Informatik 4 Kommunikation und verteilte Systeme. Middleware. Chapter 8: Middleware

Developing Java Web Services to Expose the WorkTrak RMI Server to the Web and XML-Based Clients

CA Nimsoft Service Desk

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

Brekeke PBX Web Service

Using ilove SharePoint Web Services Workflow Action

Mobility Information Series

Transcription:

Distributed Object Systems 5 XML-RPC / SOAP Piet van Oostrum What is in a Distributed Object System? Wire (transport) protocol Marshalling standard Language bindings Middle-ware (ORB) Interface specification formalism (IDL) Proxy/stub generation Object references Services September 23, 2008 Piet van Oostrum 1 Examples Corba: wire protocol: GIOP/IIOP marshalling: some not well known binary encoding DCOM: wire protocol: DCE-like marshalling: some other binary encoding Why not use standard protocols and encodings? e.g. HTTP, XML Problems Inter-operation between COM/Corba/RMI etc. difficult or impossible Different protocols Different data representation Some bridges have been built Sometimes even difficult within one system ORBs not completely compatible Security issues Does not use Internet standards (but SSL could be used) Difficult to work around firewalls System managers have to make exceptions in routers/firewalls Piet van Oostrum 2 Piet van Oostrum 3 Evolution Microsoft wanted COM on any computer: Software AG started development of COM on Unix Implementation by emulating Windows NT on top of Unix Failed miserably Some problems can be solved by using standard Internet standards/protocols E.g. XML and HTTP Widely used Thoroughly tested Platform independent Usually work through firewalls Techniques are simple and well known Standard security mechanisms available Many implementations available HTTP protocol HTTP is a simple request/response protocol Client sends a request to server Server sends a response to client HTTP message structure: A number of headers Empty line (optional) body Piet van Oostrum 4 Piet van Oostrum 5 slides5.pdf September 23, 2008 1

HTTP example without body: GET /docs/vakken/gob/index.html HTTP/1.1 Connection: Keep-Alive Host: sunshine.cs.uu.nl:8000 with body: POST /cgi-bin/form.py HTTP/1.1 Host: sunshine.cs.uu.nl:8000 Content-length: 11 Example response 200 OK Content-type: text/plain Content-length: 12 Hello, world Response can be any media type Most of them time HTML or images However, XML is better structured for data instead of visual information field=value Piet van Oostrum 6 Piet van Oostrum 7 XML-RPC XML-RPC is a RPC system with HTTP as transport protocol and XML as marshalling system. It has a fixed DTD. In principle not object-oriented (but could be used a bit OO if you fake object refrences) It is very lightweight minimal number of features easy to use not extensible fixed DTD XML-RPC example POST /RPC HTTP/1.0 User-Agent: Python Host: xloo.cs.uu.nl Content-Type: text/xml Content-length: 172 <?xml version="1.0"?> <methodcall> <methodname>stat.additem</methodname> <params> <param><value><double>3.1415</double></value> </param> </params> </methodcall> Piet van Oostrum 8 Piet van Oostrum 9 XML-RPC DTD Datatypes <!ELEMENT methodcall (methodname, params?)> <!ELEMENT methodname (#pcdata)> <!ELEMENT params (param*)> <!ELEMENT param (value)> <!ELEMENT value ( i4 int boolean string double datetime.iso8601 base64 struct array) > <!ELEMENT methodresponse (params fault)> <!ELEMENT fault (value)> <!element i4 (#pcdata)> <!element int (#pcdata)> <!element boolean (#pcdata)> <!element string (#pcdata)> <!element double (#pcdata)> <!element datetime.iso8601 (#pcdata)> <!element base64 (#pcdata)> ------------------------------------- <!element struct (member*)> <!element member (name, value)> <!element name (#pcdata)> <!element array (data)> <!element data (value*)> Piet van Oostrum 10 Piet van Oostrum 11 slides5.pdf September 23, 2008 2

Example response Fault example HTTP/1.1 200 OK Connection: close Content-Length: 155 Content-Type: text/xml Date: Fri Feb 25 09:57:17 CET 2005 Server: UserLand Frontier/5.1.2-WinNT <?xml version="1.0"?> <methodresponse> <params> <param> <value><string>south Dakota</string></value> </param> </params> </methodresponse> Piet van Oostrum 12 <?xml version="1.0"?> <methodresponse> <fault> <value> <struct> <member> <name>faultcode</name> <value><int>4</int></value> </member> <member> <name>faultstring</name> <value> <string>too many parameters</string> </value> </member> </struct> </value> </fault> </methodresponse> Piet van Oostrum 13 Python Usage example Python dynamic features import xmlrpclib server = xmlrpclib.serverproxy ("http://betty.userland.com") try: print server.examples.getstatename(41) except Error, v: print "ERROR", v Question: Where are the names example, getstatename defined? How does Python know what to do? Python has some unique features to accomodate dynamic behaviour: Attributes can be defined at runtime Attribute can magically spring into existence Any object can be made callable Any callable attribute will be considered a method Missing attributes and methods: When obj.attr or obj.attr(...) are called and obj does not have attr defined but obj has a method getattr defined then obj. getattr ( attr ) is called (The attribute name as a string is given as parameter) There is a similar setattr for assignments to attributes Piet van Oostrum 14 Piet van Oostrum 15 Callable objects Example resolved An object that has a method with name call can be called even when it is not a function object Then obj(p1,p2,...) is evaluated as obj. call (p1,p2,...) Our example: server.examples.getstatename(41) the server object doesn t have an attribute examples because it is defined without knowledge about the remote object Therefore server.examples calls server. getattr ( examples ) server. getattr creates an object This object can either accept a call (with call ) or new attributes (with getattr ). Recursively: server.examples and server.examples.getstatename are similar objects The call methods sends the name of the method and the parameters to the server with the XML-RPC protocol and returns the response Piet van Oostrum 16 Piet van Oostrum 17 slides5.pdf September 23, 2008 3

XML-RPC issues What does the method name mean? Not specified: it is up to the server How is it used? At this moment usually the client just builds the request With the help of a library How is the server used? Existing HTTP server can be used Request can be processed with CGI scripts, servlets etc. Write an application-specific server HTTP servers can be very simple Programming language support e.g. for proxies could be added What is SOAP SOAP (originally Simple Object Access Protocol) is a protocol that uses Standard Internet protocols for communication and XML for marshalling Usually HTTP, but also SMTP, FTP, etc. are possible. Communication modes: RPC, but also oneway, asynchronous messaging and the like are possible. The body of the messages can be an XML document as defined in SOAP, but also other XLM documents are possible. For documents as parameters also MIME attachments like in email are possible. The marshalling can be user-defined. Additional headers for security, transaction processing etc. are possible. Piet van Oostrum 18 Piet van Oostrum 19 Processing XML Parsing XML is usually done with SAX or DOM SAX: streaming parsing During reading/parsing when something interesting is encountered, a method from the user program is called Interesting things: element start, element end, text, processing instruction, etc. The whole document doesn t have to be in memory DOM: build a datastructure (tree-like) of the whole document in memory user program can process the tree Generating XML can be done with simple string operations Usually easier to use a higher abstraction level DOM is popular to build/manipulate XML trees SOAP processing Do-it-yourself XML manipulation and HTTP protocol processing Usually with standard HTTP (etc.) library and XML library Gives greatest flexibility, but often is tedious You have to write marshalling code yourself (can be simple read/print methods from the language) Higher abstraction that does the XML/HHTP manipulation for you Use request, parameter etc. as abstraction levels Similar to Dynamic invocation in Corba and COM Apache SOAP uses this model RPC-like calling Generally needs generated stubs and skeletons Apache Axis, Python SOAPpy library Built-in in programming language.net Piet van Oostrum 20 Piet van Oostrum 21 SOAP characteristics The method name is specified in a separate header (1.1) SOAPaction: urn:stats-com:stat#additem In SOAP 1.2 Mime content type: application/soap+xml; action= The value is a URI (URL or URN) Doesn t have to a real or existing URI Can be used by a firewall to filter requests How it is interpreted depends on the server However, there can also be a method name in the SOAP body: SOAP 1.1 specification The SOAPAction HTTP request header field can be used to indicate the intent of the SOAP HTTP request. The value is a URI identifying the intent. SOAP places no restrictions on the format or specificity of the URI or that it is resolvable. An HTTP client MUST use this header field when issuing a SOAP HTTP Request. The presence and content of the SOAPAction header field can be used by servers such as firewalls to appropriately filter SOAP request messages in HTTP. The header field value of empty string ("") means that the intent of the SOAP message is provided by the HTTP Request-URI. No value means that there is no indication of the intent of the message. <SOAP-ENV:Body> <m:getlasttradeprice xmlns:m="some-uri"> <symbol>dis</symbol> </m:getlasttradeprice> </SOAP-ENV:Body> Piet van Oostrum 22 Piet van Oostrum 23 slides5.pdf September 23, 2008 4

SOAP request body The SOAP request body contains an XML document The document has a SOAP envelope, SOAP headers and a SOAP body These are all XML elements It uses namespaces The namespace determines the SOAP version HTTP request HTTP headers SOAP processing SOAP requests can be processed by more than one processor Each processor picks up its own part from the request body and processes it It can remove that part or replace it It sends the rest of the request to the next processor Parts can be mandatory or optional Can be used e.g. for security, transactions etc. HTTP body SOAP envelope SOAP header SOAP body Piet van Oostrum 24 Piet van Oostrum 25 SOAP example HTTP headers SOAP example HTTP body POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "Some-URI" <SOAP-ENV:Envelope... <SOAP-ENV:Envelope xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:getlasttradeprice xmlns:m="some-uri"> <symbol>msft</symbol> </m:getlasttradeprice> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Piet van Oostrum 26 encodingstyle specifies what marshalling is used. There is a standard encoding style (http://schemas.xmlsoap.org/soap/encoding/) but it must be specified Different parts can use different encodingstyles. Piet van Oostrum 27 Example SOAP header SOAP datatypes The SOAP header is optional. int : 12345 <SOAP-ENV:Envelope xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/"/> <SOAP-ENV:Header> <t:transaction xmlns:t="some-uri" xsi:type="xsd:int" mustunderstand="1"> 5 </t:transaction> </SOAP-ENV:Header>... float : 2718.28E-3 negativeinteger : 98765, positiveinteger: 12345 also nonnegativeinteger, nonpositiveinteger string : How are you? Enumerations Structs Arrays Byte arrays (binary, BASE64 encoded) Polymorphic accessor, must contain the type These are defined using XML schema datatypes (XSD) Piet van Oostrum 28 Piet van Oostrum 29 slides5.pdf September 23, 2008 5

Enumerations Structs <element name="eyecolor" type="tns:eyecolor"/> <simpletype name="eyecolor" base="xsd:string"> <enumeration value="green"/> <enumeration value="blue"/> <enumeration value="brown"/> </simpletype> <e:book> <title>paradise Lost</title> <firstauthor href="http://www.dartmouth.edu/~milton/"/> </e:book> <Person> <Name>Henry Ford</Name> <Age>32</Age> <EyeColor>Brown</EyeColor> </Person> Piet van Oostrum 30 Piet van Oostrum 31 Schema Arrays <element name="book" type="tns:book"/> <complextype name="book"> <choice> <!-- Either the following group must occur or else the href attribute must appear, but not both. --> <sequence minoccurs="0" maxoccurs="1"> <element name="title" type="xsd:string"/> <element name="firstauthor" type="tns:person"/> <element name="secondauthor" type="tns:person"/> </sequence> <attribute name="href" type="urireference"/> </choice> <attribute name="id" type="id"/> </complextype> <SOAP-ENC:Array SOAP-ENC:arrayType="xsd:int[2]"> <SOAP-ENC:int>3</SOAP-ENC:int> <SOAP-ENC:int>4</SOAP-ENC:int> </SOAP-ENC:Array> Arrays can be multidimensional int[2,3] Or ragged int[][3] In this case it contains 3 arrays which can each have a different length href and id are special elements. Piet van Oostrum 32 Piet van Oostrum 33 Apache Java SOAP org.apache.soap.rpc.call object has methods to fill in the parts invoke (URL, String) calls the server. Servlets used to process the calls Example Call call = new Call (); call.setsoaptransport (ss); call.settargetobjecturi ("urn:xmltoday-delayed-quotes"); call.setmethodname ("getquote"); call.setencodingstyleuri(encodingstyleuri); Vector params = new Vector (); params.addelement (new Parameter ("symbol", String.class, symbol, null)); call.setparams (params); Response resp = call.invoke (/* router URL */ url, "" ); if (resp.generatedfault ()) { Fault fault = resp.getfault (); System.out.println ("Ouch, the call failed: "); } else { Parameter result = resp.getreturnvalue ();... Piet van Oostrum 34 Piet van Oostrum 35 slides5.pdf September 23, 2008 6

Apache Axis 1 Apache Axis 2 import org.apache.axis... import javax.xml.parsers.* import org.w3c.dom.* import org.w3c.dom.element // Build the email header DOM element DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newdocumentbuilder(); Document doc = builder.newdocument(); Element emailelem = doc.createelementns( "http://www.skatestown.com/", "EMail"); emailelem.appendchild(doc.createtextnode(email)); // Build the RPC request SOAP message SOAPEnvelope reqenv = new SOAPEnvelope(); reqenv.addheader(new SOAPHeader(emailElem)); Object[] params = new Object[]{ sku, new Integer(quantity), reqenv.addbodyelement(new RPCElement("", "docheck", params) // Invoke the inventory check web service ServiceClient call = new ServiceClient(url); SOAPEnvelope respenv = call.invoke(reqenv); // Retrieve the response RPCElement resprpc = (RPCElement)respEnv.getFirstBody(); RPCParam result = (RPCParam)respRPC.getParams().get(0); Piet van Oostrum 36 Piet van Oostrum 37 Apache Axis 3 WSDL2Java tool Generates Java Classes for client stubs For example for a HelloWorld application: HelloWorld.java HelloWorldLocator.java HelloWorldSoap.java HelloWorldSoapStub.java Apache Axis 4 This is how the client program looks like: public class Client { public static void main(string [] args) { try { HelloWorldLocator loc = new HelloWorldLocator(); HelloWorldSoap port = loc.gethelloworldsoap(); System.out.println(port.sayHelloWorld()); } catch(exception e) {System.out.println(e.getMessage());} } } Piet van Oostrum 38 Piet van Oostrum 39 Python example Python has callable objects Class can override the call () operator Undefined method names and attributes can be intercepted import soaplib server = soaplib.serverproxy( "http://superhonker.userland.com:80/examples") print server.getcurrenttime() print server.getstatename(41) WSDL/UDDI WSDL Web Services Description Language Uses XML to describe Web Services Used as an IDL for SOAP Can be used as a more general description mechanism Uses XML schemas for types UDDI - Universal Description, Discovery and Integration Kind of telephone directory for web services (yellow pages) class Payload: def init (self): self.a = 1 self.b = 2 print server.getstatestruct(payload()) Piet van Oostrum 40 Piet van Oostrum 41 slides5.pdf September 23, 2008 7