Web Services

Denis Helic

IICM, TU Graz

Web as a database

Web as a platform for distributed systems

Types of services (1)

Types of services (2)

Kind of Things on the Programmable Web

Classification based on architectural design

Method information (1)

Method information (2)

Method information (3)

Method information (3)

	wsdl_uri = 'http://api.google.com/GoogleSearch.wsdl'
	driver = SOAP.create_rpc_driver(wsdl_uri)
	result_set = driver.doGoogleSearch(...)

Method information (4)

	POST search/beta2 HTTP/1.1
	...	
	<soap:Envelope>
		<soap:Body>
			<gs:doGoogleSearch>
				<q>REST</q>
			</gs:doGoogleSearch>
		</soap:Body>
	</soap:Envelope>

Method information (5)

	<operation name="doGoogleSearch">
		<input message="typens:doGoogleSearch" />
		<output message="typens:doGoogleSearchResponse" />
	</operation>

Scoping information (1)

Scoping information (2)

Scoping information (3)

Scoping information (4)

	POST search/beta2 HTTP/1.1
	...	
	<soap:Envelope>
		<soap:Body>
			<gs:doGoogleSearch>
				<q>REST</q>
			</gs:doGoogleSearch>
		</soap:Body>
	</soap:Envelope>

Competing Architectures

RESTful, Resource-Oriented Architectures

RPC-Style Architectures (1)

RPC-Style Architectures (2)

RPC-Style Architectures (3)

	
	<methodCall>
		<methodName>lookupUPC</methodName>
		<params>
			<gs:param>
				<value>
					<string>0920985</string>
				</value>
			</gs:param>
		</params>
	</methodCall>

RPC-Style Architectures (4)

REST-RPC Hybrid Architectures (1)

REST-RPC Hybrid Architectures (2)

	GET services/rest?method=flickr.photos.search&tags=penguin HTTP/1.1
	Host: www.flickr.com

Big Web Services

Sample SOAP service (1)

public class EchoService {
    public String echo(String msg) {
        return msg;
    }
}

Sample SOAP service (2)

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
    <echo>
      <msg>Hello World!</msg>
    </echo>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Sample SOAP service (3)

Sample SOAP service (4)

<soapenv:Envelope>
 <soapenv:Body>
  <ns1:echo>
   <ns1:arg0 xsi:type="soapenc:string" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    Hello World!
   </ns1:arg0>
  </ns1:echo>
 </soapenv:Body>
</soapenv:Envelope>

Sample SOAP service (5)

SOAP/WSDL Frameworks (1)

SOAP/WSDL Frameworks (2)

SOAP and WSDL in Axis (1)

SOAP and WSDL in Axis (1)

SOAP and WSDL in Axis (2)

SOAP and WSDL in Axis (3)

Axis - An Example (1)

Axis - An Example (2)

....
public void storePerson(Person person);
public Iterator readAllPersons();
public Person readPersonWithId(int id);
....

Axis - An Example (2)

org.apache.axis.wsdl.Java2WSDL 
-o persondao.wsdl 
-l"http://coronet2.iicm.edu/axis/services/persondao" 
-n urn:coronet.iicm.edu/persondao 
-p"edu.iicm.publication.db" coronet.iicm.edu/persondao 
edu.iicm.publication.db.PersonDAO

Axis - An Example (3)

org.apache.axis.wsdl.WSDL2Java
-o src 
-d Session 
-s 
-p edu.iicm.publication.db.ws 
persondao.wsdl

Axis - An Example (4)

package edu.iicm.publication.db.ws;
public interface PersonDAO extends java.rmi.Remote {
 public void storePerson(edu.iicm.publication.db.ws.Person in0) 
  throws java.rmi.RemoteException;
 public java.lang.Object readAllPersons() 
  throws java.rmi.RemoteException;
 public edu.iicm.publication.db.ws.Person readPersonWithId(int in0) 
  throws java.rmi.RemoteException;
}

Axis - An Example (5)

package edu.iicm.publication.db.ws;
public class Person implements java.io.Serializable {
 private int id;
...
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
...

Axis - An Example (6)

public java.lang.Object readAllPersons() 
 throws java.rmi.RemoteException {
...
 org.apache.axis.client.Call _call = createCall();
 _call.setOperation(_operations[1]);
 _call.setUseSOAPAction(true);
 _call.setSOAPActionURI("");
 _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
...

Axis - An Example (7)

...
 _call.setOperationName(
  new javax.xml.namespace.QName(
    "urn:coronet.iicm.edu/persondao", 
    "readAllPersons"));
 setRequestHeaders(_call);
 setAttachments(_call);
 java.lang.Object _resp = 
  _call.invoke(new java.lang.Object[] {});
...

Axis - An Example (8)

...
public edu.iicm.publication.db.ws.Person 
 readPersonWithId(int in0) 
 throws java.rmi.RemoteException {
 edu.iicm.publication.db.PersonDAO dao = 
  DAOFactory.createPersonDAO();        
...

Axis - An Example (9)

...
 edu.iicm.publication.Person person = 
  dao.readPersonWithId(in0);
 edu.iicm.publication.db.ws.Person out0 = 
  new edu.iicm.publication.db.ws.Person();
 out0.setId(person.getId());
 out0.setName(person.getName());
 out0.setRole(person.getRole());
 return out0;
}
...

Axis - An Example (10)

...
PersonDAOServiceLocator locator = new PersonDAOServiceLocator();
       
try {
 PersonDAO dao = locator.getpersondao();
 Person person = new Person();
 person.setName(name);
 dao.storePerson(person);     
 log_.debug("Person stored");
...

Problems of SOAP/WSDL (1)

Problems of SOAP/WSDL (2)

Problems of SOAP/WSDL (3)

Problems of SOAP/WSDL (4)