Remote Procedure Calling

Slides:



Advertisements
Similar presentations
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
Advertisements

Web forms and CGI scripts Dr. Andrew C.R. Martin
31242/32549 Advanced Internet Programming Advanced Java Programming
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
General introduction to Web services and an implementation example
Introduction to Computing Using Python CSC Winter 2013 Week 8: WWW and Search  World Wide Web  Python Modules for WWW  Web Crawling  Thursday:
SOAP.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
Web Services Nasrullah. Motivation about web service There are number of programms over the internet that need to communicate with other programms over.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
Web Services CS Web Services Internet-available services using XML messaging, for computer-computer interaction Not tied to any OS or language Self-describing:
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Processing of structured documents Spring 2003, Part 6 Helena Ahonen-Myka.
INTRODUCTION TO WEB DATABASE PROGRAMMING
HTTP HTTP stands for Hypertext Transfer Protocol. It is an TCP/IP based communication protocol which is used to deliver virtually all files and other.
Enabling Embedded Systems to access Internet Resources.
1 HKU CSIS DB Seminar: HKU CSIS DB Seminar: Web Services Oriented Data Processing and Integration Speaker: Eric Lo.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Lecture 15 Introduction to Web Services Web Service Applications.
Distributed Systems Concepts and Design Chapter 4.
Web Services BOF This is a proposed new working group coming out of the Grid Computing Environments Research Group, as an outgrowth of their investigations.
Copyright © 2013 Curt Hill SOAP Protocol for exchanging data and Enabling Web Services.
1 Web Services Web and Database Management System.
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Kemal Baykal Rasim Ismayilov
CSIT 220 (Blum)1 Remote Procedure Calls Based on Chapter 38 in Computer Networks and Internets, Comer.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
S O A P ‘the protocol formerly known as Simple Object Access Protocol’ Team Pluto Bonnie, Brandon, George, Hojun.
Advanced Web Technologies Lecture #4 By: Faraz Ahmed.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
Web Services An Introduction Copyright © Curt Hill.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
1/30/20161 Introduction to Web Services Bina Ramamurthy
COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Revision Lecture: HTML, CSS and XML Perl/CGI, Perl/DOM, Perl/DBI, Remote Procedure Calls Dr. Andrew C.R. Martin
National College of Science & Information Technology.
Midterm Review October Closed book one hand written page of notes of your own making October Closed book one hand written page of notes of.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Java Web Services Orca Knowledge Center – Web Service key concepts.
COMP2322 Lab 4 Socket Programming
Web fundamentals: Clients, Servers, and Communication
Tiny http client and server
CS 330 Class 7 Comments on Exam Programming plan for today:
Section 6.3 Server-side Scripting
WWW and HTTP King Fahd University of Petroleum & Minerals
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Sabri Kızanlık Ural Emekçi
WEB SERVICES From Chapter 19 of Distributed Systems Concepts and Design,4th Edition, By G. Coulouris, J. Dollimore and T. Kindberg Published by Addison.
WEB SERVICES.
Unit – 5 JAVA Web Services
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
Implementing a service-oriented architecture using SOAP
WEB API.
Web Server Administration
Process-to-Process Delivery:
Introduction to Web Services
Creating a Distributed System with Remote Procedure Calls and Web Services Ch.5 B.Ramamurthy 2/17/2019 B.Ramamurthy.
William Stallings Data and Computer Communications
WEB SERVICES From Chapter 19, Distributed Systems
Introduction to Web Services and SOA
Traditional Internet Applications
Process-to-Process Delivery: UDP, TCP
Chengyu Sun California State University, Los Angeles
Presentation transcript:

Remote Procedure Calling Dr. Andrew C.R. Martin andrew.martin@ucl.ac.uk http://www.bioinf.org.uk/

Aims and objectives Understand the concepts of remote procedure calling and web services To be able to describe different methods of remote procedure calls Understand the problems of ‘screen scraping’ Know how to write code using urllib.request

What is RPC? A network accessible interface to application Web Service Network A network accessible interface to application functionality using standard Internet technologies

Why do RPC? distribute the load between computers access to other people's methods access to the latest data

Ways of performing RPC screen scraping simple cgi scripts (REST) custom code to work across networks standardized methods (e.g. CORBA, SOAP, XML-RPC)

Web services RPC methods which work across the internet are often called “Web Services” Web Services can also be self-describing (WSDL) provide methods for discovery (UDDI)

Screen scraping

Web service Web service Network

Screen scraping Extracting content from a web page Web server Screen scraper Web server Network Extracting content from a web page

Fragile procedure... Extract Data Web data page Provider Consumer Data Partial data Semantics lost Data Extract data Web page Errors in data extraction Visual markup Provider Consumer Data Partial error- prone data Extract data

Fragile procedure... Trying to interpret semantics from display-based markup If the presentation changes, the screen scraper breaks

Web servers… Pages CGI Script RDBMS External Programs Web browser Send request for page to web server CGI Script Web browser Web server RDBMS External Programs

Screen scraping Straightforward in Python Python urllib.request module trivial to write a web client Pattern matching and string handling routines

Example scraper… A program for secondary structure prediction Want a program that: specifies an amino acid sequence provides a secondary structure prediction Using a remote server!

We want to be able to do: #!/usr/bin/env python3 seq = """KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDY GILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNR CKGTDVQAWIRGCRL""" seq = seq.replace('\n', '') ss = PredictSS(seq) if(ss != ""): print (seq) print (ss)

Add a dummy test routine #!/usr/bin/env python3 def PredictSS(seq): retval = '' for i in range(0, len(seq)): retval += '?' return(retval) seq = """KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDY GILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNR CKGTDVQAWIRGCRL""" seq = seq.replace('\n', '') ss = PredictSS(seq) if(ss != ""): print (seq) print (ss)

Results: Obviously we wish to replace PredictSS() KVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQATNRNTDGSTDYGILQINSR WWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDGNGMNAWVAWRNRCKGTDVQA WIRGCRL ????????????????????????????????????????????????????????????? ??????? Obviously we wish to replace PredictSS()

Example scraper… NNPREDICT web server at alexander.compbio.ucsf.edu/~nomi/nnpredict.html alexander.compbio.ucsf.edu/cgi-bin/nnpredict.pl Unfortunately no longer available. Dummy version: www.bioinf.org.uk/teaching/bbk/biocomp2/rpc/nnpredict/ www.bioinf.org.uk/teaching/bbk/biocomp2/rpc/nnpredict/nnpredict.cgi

Example scraper… Program must: Examine the source for the page… connect to web server submit the sequence obtain the results and extract data Examine the source for the page…

<b>Tertiary structure class:</b> <form method="POST” action="http://alexander.compbio.ucsf.edu/cgi-bin/nnpredict.pl"> <b>Tertiary structure class:</b> <input TYPE="radio" NAME="option" VALUE="none" CHECKED> none VALUE="all-alpha"> all-alpha VALUE="all-beta"> all-beta VALUE="alpha/beta"> alpha/beta <b>Name of sequence</b> <input name="name" size="70"> <b>Sequence</b> <textarea name="text" rows=14 cols=70></textarea> </form>

Example scraper… option 'none', 'all-alpha', 'all-beta', or 'alpha/beta' name optional name for the sequence text the sequence

Example scraper… from urllib import request def PredictSS(seq): "bbk/biocomp2/rpc/"\ "nnpredict/nnpredict.cgi" params = "option=none&name=&text=" + seq fullurl= url + "?" + params result = request.urlopen(fullurl).read() result = str(result, encoding='utf-8') if(result != ''): ss = ParseSS(result) return(ss) else: sys.stderr.write("Nothing was returned\n") return("")

Example scraper… Specify URL and parameters from urllib import request def PredictSS(seq): url = "http://www.bioinf.org.uk/teaching/"\ "bbk/biocomp2/rpc/"\ "nnpredict/nnpredict.cgi" params = "option=none&name=&text=" + seq fullurl= url + "?" + params result = request.urlopen(fullurl).read() result = str(result, encoding='utf-8') if(result != ''): ss = ParseSS(result) return(ss) else: sys.stderr.write("Nothing was returned\n") return("") Specify URL and parameters

convert from byte string Example scraper… from urllib import request def PredictSS(seq): url = "http://www.bioinf.org.uk/teaching/"\ "bbk/biocomp2/rpc/"\ "nnpredict/nnpredict.cgi" params = "option=none&name=&text=" + seq fullurl= url + "?" + params result = request.urlopen(fullurl).read() result = str(result, encoding='utf-8') if(result != ''): ss = ParseSS(result) return(ss) else: sys.stderr.write("Nothing was returned\n") return("") Retrieve data and convert from byte string

Example scraper… Extract required info From the HTML from urllib import request def PredictSS(seq): url = "http://www.bioinf.org.uk/teaching/"\ "bbk/biocomp2/rpc/"\ "nnpredict/nnpredict.cgi" params = "option=none&name=&text=" + seq fullurl= url + "?" + params result = request.urlopen(fullurl).read() result = str(result, encoding='utf-8') if(result != ''): ss = ParseSS(result) return(ss) else: sys.stderr.write("Nothing was returned\n") return("") Extract required info From the HTML

<HTML><HEAD> <TITLE>NNPREDICT RESULTS</TITLE> </HEAD> <BODY bgcolor="F0F0F0"> <h1 align=center>Results of nnpredict query</h1> <p><b>Tertiary structure class:</b> alpha/beta <p><b>Sequence</b>:<br> <tt> MRSLLILVLCFLPLAALGKVFGRCELAAAMKRHGLDNYRGYSLGNWVCAAKFESNFNTQA<br> TNRNTDGSTDYGILQINSRWWCNDGRTPGSRNLCNIPCSALLSSDITASVNCAKKIVSDG<br> NGMNAWVAWRNRCKGTDVQAWIRGCRL<br> </tt> <p><b>Secondary structure prediction <i>(H = helix, E = strand, - = no prediction)</i>:<br></b> ----EEEEEEE-H---H--EE-HHHHHHHHHH--------------HHHHHH--------<br> ------------HHHHE-------------------------------HH-----EE---<br> ---HHHHHHH--------HHHHHHH--<br> </body></html>

Example scraper… import re def ParseSS(result): result = result.replace('\n','') result = result.replace('<br>','') p = re.compile('^.*<tt>(.*)<\/tt>.*$') m = p.match(result) result = m.group(1) # Returns the () match return(result)

Example scraper… Remove returns and <br> tags import re def ParseSS(result): result = result.replace('\n','') result = result.replace('<br>','') p = re.compile('^.*<tt>(.*)<\/tt>.*$') m = p.match(result) result = m.group(1) # Returns the () match return(result)

Example scraper… Create and match regular expression import re def ParseSS(result): result = result.replace('\n','') result = result.replace('<br>','') p = re.compile('^.*<tt>(.*)<\/tt>.*$') m = p.match(result) result = m.group(1) # Returns the () match return(result) Create and match regular expression

Example scraper… If authors changed presentation import re def ParseSS(result): result = result.replace('\n','') result = result.replace('<br>','') p = re.compile('^.*<tt>(.*)<\/tt>.*$') m = p.match(result) result = m.group(1) # Returns the () match return(result) Extract the () group match If authors changed presentation of results, this may well break!

Pros and cons Advantages Disadvantages 'service provider' doesn’t do anything special Disadvantages screen scraper will break if format changes may be difficult to determine semantic content

Simple CGI scripts REST: Representational State Transfer http://en

Simple CGI scripts Extension of screen scraping relies on service provider to provide a script designed specifically for remote access Client identical to screen scraper but guaranteed that the data will be parsable (plain text or XML)

Simple CGI scripts Server's point of view provide a modified CGI script which returns plain text May be an option given to the CGI script

Simple CGI scripts Search using EUtils is performed in 2 stages: 'Entrez programming utilities' http://eutils.ncbi.nlm.nih.gov/entrez/query/static/eutils_help.html Search using EUtils is performed in 2 stages: specified search string returns a set of PubMed Ids fetch the results for each of these PubMed IDs in turn.

Simple CGI scripts I have provided a script you can try to extract papers from PubMed (Note this is in Perl not Python) You can try Web Services that we have provided at: www.bioinf.org.uk/pdbsws/cgi.html www.bioinf.org.uk/abs/abdb/ws.cgi

Custom code

Custom code Generally used to distribute tasks on a local network Code is complex low-level OS calls sample on the web

Custom code Link relies on IP address and a 'port’ Ports tied to a particular service port 80 : HTTP port 22 : ssh See /etc/services

Custom code Generally a client/server model: server listens for messages client makes requests of the server Client Server request message response message

Custom code: server Server creates a 'socket' and 'binds' it to a port Listens for a connection from clients Responds to messages received Replies with information sent back to the client

Custom code: client Client creates a socket Binds it to a port and the IP address of the server Sends data to the server Waits for a response Does something with the returned data

Standardized Methods

Standardized methods Various methods. e.g. CORBA XML-RPC SOAP Will now concentrate on SOAP...

Advantages of SOAP Web service Application client Application code Platform and language independent code Platform and language specific code

Advantages of SOAP Information encoded in XML Language independent Application XML message Application Information encoded in XML Language independent All data are transmitted as simple text

Advantages of SOAP Normally uses HTTP for transport HTTP post  SOAP request HTTP response  SOAP response Normally uses HTTP for transport Firewalls allow access to the HTTP protocol Same systems will allow SOAP access

Advantages of SOAP W3C standard Libraries available for many programming languages

SOAP Header (optional) SOAP messages SOAP Envelope SOAP Header (optional) Header block Header block SOAP Body Message body

Example SOAP message Header block Message body Specifies data must be handled as a single 'transaction’ Message body contains a sequence simply encoded in XML Perfectly legal, but more common to use special RPC encoding

Subroutine calls Only important factors the type of the variables the order in which they are handed to the subroutine

SOAP transport SOAP is a packaging protocol which provides standard encoding for variables: Integers, floats, strings, arrays, hashes, structures Layered on networking and transport SOAP doesn't care what these are

SOAP transport Generally uses HTTP, but may also use: FTP, raw TCP, SMTP, POP3, Jabber, etc. HTTP is pervasive across the Internet. Request-response model of RPC matches HTTP

Web application server A simple SOAP server HTTPD Simple SOAP-specific CGI script Application code Service Listener Service Proxy Application specific code Web application server

Summary RPC allows access to methods and data on remote computers Four main ways of achieving this Screen scraping Special CGI scripts Custom code Standardized methods (SOAP, etc.)

Summary SOAP has not caught on as much as was hoped REST is much simpler to implement and to understand REST is simply a CGI script BOOKS: Mitchell (2015) Web Scraping with Python – Collecting Data from the Modern Web. O'Reilly Richardson et al. (2013) RESTful Web APIs. O'Reilly Amundsen (2016) RESTful Web Clients. O'Reilly