Information infrastructure ii
1 / 31

Information Infrastructure II - PowerPoint PPT Presentation

  • Updated On :

Information Infrastructure II. I211 Week 14 Rajarshi Guha. Outline. Web services WSDL SOAP SOAPpy. Distributed Computing. CGI programs are an example Code is running on some machine We write code that access this code Based on constructing URL’s Remote functions are handy

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Information Infrastructure II' - Antony

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Information infrastructure ii l.jpg

Information Infrastructure II

I211 Week 14

Rajarshi Guha

Outline l.jpg

  • Web services

    • WSDL

    • SOAP

  • SOAPpy

Distributed computing l.jpg
Distributed Computing

  • CGI programs are an example

    • Code is running on some machine

    • We write code that access this code

    • Based on constructing URL’s

  • Remote functions are handy

    • Utilize better machines

    • Access software

    • Doesn’t require maintenance

Distributed computing4 l.jpg
Distributed Computing

  • CGI’s are easy to use

    • Limited in the types of things that can be returned

    • Everything must be a string

What is a web service ws l.jpg
What is a Web Service (WS) ?

  • Code running on an arbitrary machine that can be accessed in a platform- and language-independent fashion

  • More generally, a WS framework is an XML-based distributed services system.

    • Suitable for machine-to-machine interaction

    • Platform & language agnostic

    • Follows standards

Slide6 l.jpg





















DB or


DB or


Basic Architectures:CGI and Web Services


Famous web services l.jpg
Famous Web Services

  • Google

    • Access their search engine

    • Access Google Maps

  • Amazon

    • Access their search engine

    • Access historical data

Iu web services l.jpg
IU Web Services

  • Variety of public cheminformatics services

    • Molecular descriptors

    • 2D structure diagrams

    • TPSA

    • Fingerprints

    • Similarity calculations

    • Toxicity class predictions

Some terminology l.jpg
Some Terminology

  • SOAP – Simple Object Access Protocol. Describes how data will be encoded when it's sent to a service and decoded when received from a service

  • WSDL – Web Service Description LanguageDescribes how a client should interact with a web service

  • Application Container – software that hosts services

The components of a ws l.jpg

Client side

Some libraries

Client code

Client code might be

Stand alone program

Web browser

The Components of a WS

  • Server side

    • Web server

    • Application container

    • Service code

  • Web server can be optional

  • Container can be optional

Programming languages l.jpg
Programming Languages

  • Your favorite language!

  • Support exists for

    • C/C++

    • Java

    • Perl

    • Python

    • PHP

    • Ruby

    • .Net (so you can access WS's from Excel)

Web service description language l.jpg
Web Service Description Language

  • WSDL is an XML-based description of a web service

  • It describes

    • what type of objects it accepts and returns and what type of exceptions can occur amongst other things

  • This is what makes a WS independent of language

  • What do we do with WSDL?

    • Look at it and write a client

    • Generate a proxy and use that in the client

What does wsdl look like l.jpg
What Does WSDL Look Like?

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions targetNamespace="http://office:8080/axis/services/CDKstruct3D" xmlns:apachesoap="" xmlns:impl="http://office:8080/axis/services/CDKstruct3D" xmlns:intf="http://office:8080/axis/services/CDKstruct3D" xmlns:soapenc="" xmlns:tns1="" xmlns:wsdl="" xmlns:wsdlsoap="" xmlns:xsd="">

<!--WSDL created by Apache Axis version: 1.2RC2

Built on Nov 16, 2004 (12:19:44 EST)-->


<schema targetNamespace="" xmlns="">

<import namespace=""/>

<complexType name="CDKException">





<wsdl:message name="CDKException">

<wsdl:part name="fault" type="tns1:CDKException"/>


<wsdl:message name="get3DCoordinatesResponse">

<wsdl:part name="get3DCoordinatesReturn" type="soapenc:string"/>


<wsdl:message name="get3DCoordinatesRequest">

<wsdl:part name="in0" type="soapenc:string"/>

<wsdl:part name="in1" type="soapenc:string"/>


<wsdl:portType name="CDKstruct3D">

<wsdl:operation name="get3DCoordinates" parameterOrder="in0 in1">

<wsdl:input message="impl:get3DCoordinatesRequest" name="get3DCoordinatesRequest"/>

<wsdl:output message="impl:get3DCoordinatesResponse" name="get3DCoordinatesResponse"/>

<wsdl:fault message="impl:CDKException" name="CDKException"/>




What is the result of this l.jpg
What is the Result of This?

  • Examining the WSDL gives us the following information about the CDKstruct3D service

    • Location of the service

    • It takes 2 inputs, which will be SOAP encoded strings

    • It returns a SOAP encoded string

    • It may return a fault of type CDKException

  • But we need to know what the arguments mean

    • Got to ask the author!

Simple object access protocol l.jpg
Simple Object Access Protocol

  • SOAP is an XML message format (encoding)

    • Describes how an object is represented when sent to or received from a service

  • SOAP messages have to be sent to the service

    • Usually over HTTP

  • SOAP is usually linked to WSDL

  • What does a SOAP message contain?

    • Headers

    • Payload – arbitrary XML

What does soap look like l.jpg
What Does SOAP Look Like?

<?xml version="1.0" encoding="UTF-8"?>












<v1 xsi:type="xsd:string">CC=COC</v1>

<v2 xsi:type="xsd:int">1024</v2>

<v3 xsi:type="xsd:int">6</v3>





What types does soap allow l.jpg
What Types Does SOAP Allow?

  • SOAP specifies a number of primitive built in types

    • int, double, float, boolean, String, Date, arrays etc.

  • Some compound types also allowed

    • arrays, hashes etc

  • So when making a request using SOAP we need to convert objects to a proper SOAP type

    • The required type is described in the WSDL

  • Luckily we don't need to deal with raw SOAP messages

    • The SOAP toolkit (AXIS for us) will handle it

Other clients the web page l.jpg
Other Clients – The Web Page

  • It's handy to have a web page that provides a form interface

  • Depends onwhether the WS isuseful as a webpage

  • Very easy with the PHP

Other clients the web page19 l.jpg
Other Clients – The Web Page

The PHP code

called by the





function CallTPSAService($t) {

$client = new


$params = array('smiles'=>trim($t));

$soapoptions = array('timeout' => 360);

$tpsa = $client->call('getTPSA',$params,$soapoptions);

if (PEAR::isError($ret)) {

// handle error

} else {

// make a nice web page



$smiles = $_POST['smiles']





<form action="phptpsa.php" method="post" enctype=




<td><input name="smiles" type="text" /></td>


<input type="submit" value="Get TPSA" />




Python ws clients l.jpg
Python WS Clients

  • Need to get the WSDL

  • Ideally, we should have documentation

    • We can determine available methods and arguments programmatically

    • Still won’t know what they mean

  • Calling a web service is the same as calling a function

Soappy l.jpg

  • We’ll use the SOAPpy module to interact with a web service

  • Handles the conversion to and from SOAP messages

    • We send and receive ordinary Python types

  • Installed on Sulu

Connecting to a web service l.jpg
Connecting to a Web Service

  • Create a proxy object representing the web service

url = ‘’

s = SOAPpy.WSDL.Proxy(url)

print s

<SOAPpy.WSDL.Proxy instance at 0x20000000042dd050>

The proxy object l.jpg
The Proxy Object

  • Behaves just like a class or module

  • The WS methods are just like methods of a class or module

    • Just send the proper arguments like any other function

sim = s.getSimilarity(‘CCC’, ‘CCCO’)

print sim


Public web services l.jpg
Public Web Services

  • X-methods is a collection of public web services

  • Getting a recipe of the day

url = '’

s = SOAPpy.WSDL.Proxy(url)

print s.ForToday()

Interrogating a web service l.jpg
Interrogating a Web Service

  • Sometimes it’s useful to find out what methods are associated with a service

  • For each method we also want to know

    • The arguments for the service

    • The return type of the method

Getting a list of methods l.jpg
Getting a List of Methods

  • The proxy object has a member called methods

    • A dictionary

    • The keys are the method names

    • The values are SOAPCallInfo instances

url = '’

s = SOAPpy.WSDL.Proxy(url)

print s.methods

print s.methods.keys()

Interrogating a method l.jpg
Interrogating a Method

  • We can get the object representing a WS method from the methods dictionary

  • A method object has two members

    • inparams

    • outparams

  • These are lists of ParameterInfo objects

    • We don’t need to bother with the details

  • Each such object contains the name and type of the arguments (or return value)

Interrogating a method arguments l.jpg
Interrogating a Method - Arguments

>>> m = s.methods['getSimilarity’]

>>> m.inparams

[<SOAPpy.wstools.WSDLTools.ParameterInfo instance at 0x244fa9e0>,

<SOAPpy.wstools.WSDLTools.ParameterInfo instance at 0x24faa28>]

>>> m.inparams[0].name


>>> m.inparams[0].type

(u'', u'string')

Interrogating a method return value l.jpg
Interrogating a Method - Return Value

>>> m = s.methods['getSimilarity’]

>>> m.outparams

[<SOAPpy.wstools.WSDLTools.ParameterInfo instance at 0x200044faa70>]

>>> m.outparams[0].name


>>> m.outparams[0].type

(u'', u'double')

Summary of methods l.jpg
Summary of Methods

  • Very easy to get available methods and their parameter names and datatypes

>>> from SOAPpy import WSDL

>>> service = WSDL.Proxy('http://localhost:8080/axis/services/CDKws?wsdl')

>>> service.methods.keys()

[u'getMolecularWeight', u'getMolecularFormula', u'getFingerprintVector', u'getFingerprintString', u'getHTMLMolecularFormula', u'getTPSA']

>>> fpMethod = service.methods['getFingerprintVector']

>>> fpMethod.inparams[0].name


>>> fpMethod.inparams[0].type

(u'', u'string')


>>> fpMethod.outparams[0].name


>>> fpMethod.outparams[0].type

(u'', u'Vector')

Alternatives l.jpg

  • SOAPpy is not maintained anymore

    • Very easy to use

    • Does’t support more complex (useful) types

  • ZSI is the preferred SOAP library to use for Python

    • Steeper learning curve