0% found this document useful (0 votes)
955 views16 pages

Client-Server Computational Model Middleware: Lecture Objectives

Web service

Uploaded by

arnoldgm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
955 views16 pages

Client-Server Computational Model Middleware: Lecture Objectives

Web service

Uploaded by

arnoldgm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

ECE/CS 4984

Wireless and Mobile Systems Design


Spring 2003

Lecture 4
Client-Server Computational
Model Middleware

Ing-Ray Chen
Copyright Reserved

Lecture Objectives
• Differentiate and exemplify client-server, client-
agent-server, and client-intercept-server model
middleware
• Understand functionality provided by middleware for
client-side, agent-side, and server-side software
development
• Understand how client-server computational model
middleware is able to deal with wireless device
heterogeneity and scalability issues
• Characterize design requirements of example client-
server applications (e.g., wireless and mobile web
access) and rationalize the choice of middleware
and design for application development

ECE/CS 4984, Spring 2003 2 Client-Server Computational Model Middleware

1
Sources
• D. Ferguson, Mobile .NET, a! APress, 2002.
• http://www.wapforum.org/
• http://www.wapforum.com/
• http://www.nttdocomo.com/ - for i-mode.
• http://www.pocketsoap.com/ - for PocketSOAP
• http://www.ksoap.org/ - for kSOAP
• http://msdn.microsoft.com/vstudio/device/mobilecon
trols/default.asp - for Microsoft’s Mobile Internet
Toolkit (MIT)
• http://www.learnxmlws.com/tutors/wsdl/wsdl.aspx -
for WSDL

ECE/CS 4984, Spring 2003 3 Client-Server Computational Model Middleware

Agenda
• Client-Server Computational Models
• XML-based technology for facilitating wireless web
access from smart devices
! Small Object Access Protocol (SOAP)
! Web Service Description Language (WSDL)
! Example 1: Embedded Visual Tool + PocketSOAP for iPAQs
! Example 2: J2ME + kSOAP for J2ME-enabled devices
• Microsoft Mobile Internet Toolkit (MIT)
! Introduction to server-side development environment
! Learn how to design server-side .NET software to be
accessed from heterogeneous mobile devices such as
Pocket PCs, i-mode, WAP-enabled devices, etc.

ECE/CS 4984, Spring 2003 4 Client-Server Computational Model Middleware

2
Client-Server Models for Wireless Mobile
Computing (1)
• Mobile client-server
! Message passing with queueing
! Remote procedure call
" Synchronous: inadequate since the client is blocked in case of
disconnection
" Asynchronous: client requests can be queued locally and
control is returned immediately to the client. When the mobile is
connected, the queue is drained in the background and any
queued RPC is forwarded to the server
! Optimization involves changes to both the client and server
Application Application
Wireless Server
Client link
Fixed
Mobile network
host
ECE/CS 4984, Spring 2003 5 Client-Server Computational Model Middleware

Client-Server Models for Wireless Mobile


Computing (2)
• Client-agent-server
! Computation is split into client-agent (wireless) and agent-server
(wired)
! To deal with disconnection: Clients can submit requests to the agent
and retrieve responses from the agent upon reconnection
! The agent can employ optimization and transformation techniques to
the data to be transmitted depending on the type of data, the type of
devices and application-specific requirements
! Example:
" Mobile client - WAP gateway - WAP server
" Lab 4: client – server proxy - web server

Fixed network

Application Application
Client
Wireless Agent Server
link
Mobile
host

ECE/CS 4984, Spring 2003 6 Client-Server Computational Model Middleware

3
Client-Server Models for Wireless Mobile
Computing (3)
• Client-Intercept-server
! Inter-agent optimization protocols can be performed between the
client-side and server-side agents to minimize communication cost
via caching, differencing, header reduction, one-HTTP connection per
session, etc.
! Caching/prefetching at the client agent to allow disconnected
operations, e.g., via ADO .NET/SQL server CE
! Example: IBM Web Express: Web Browser (client) - HTTP - Client side
agent - TCP/IP connection <-> Server side agent - Web server

Application Client Server Application


Wireless Side Server
Client Side link
Agent Mobile Agent
host

ECE/CS 4984, Spring 2003 7 Client-Server Computational Model Middleware

XML
• XML (Extensible Markup Language) – A platform-neural data
standard for describing, storing and transporting data across the
web
• XML is a core technology for web services
! Use XML as a basis for separately developed web services to interact
with each other
! Use XML to facilitate component developments
" Packaging application functionality as smaller, easily connected
web services
" Composing an application using “web services” components
• XML and .NET: .NET is a Microsoft technology to develop XML
web services on many platforms
! .NET ASP (Active Server Page) can be used to develop web services
! .NET CF can be used to develop web services on small devices
! MIT (Microsoft Internet Toolkit) can be used to develop server-side
proxy to deal with heterogeneous mobile devices

ECE/CS 4984, Spring 2003 8 Client-Server Computational Model Middleware

4
XML and Wireless Web Access
• The synergy between XML and wireless can be
considered from two perspectives:
! XML has emerged as the data representation technology
facilitating content delivery (via XML transformation) to a
wide variety of mobile devices and platforms
! XML is a meta-language (a set of rules to define domain-
specific data definition languages), thus driving the success
of XML-based wireless web access initiatives including:
" WML, an XML-compliant language used by WAP 1.0
" XHTML, an XML-compliant language adopted by WAP 1.2
and future i-mode
" WSDL (Web Service Description Language), an XML-
compliant language normally used in a WSDL document
to describe a web service's interface, i.e., providing
clients with information on how to invoke a web service.

ECE/CS 4984, Spring 2003 9 Client-Server Computational Model Middleware

XML Transformation
• XML separates the data
from a fixed description
of how the data should be cHTML
displayed
• XSL (Extensible Style-
Sheet Language)
describes how to display
content XML XSLT XHTML
! XSLT is an XML-based
transformation
technology to
programmatically
transform XML data into WML
other mobile
device/platform specific
formats such as cHTML,
XHTML and WML

ECE/CS 4984, Spring 2003 10 Client-Server Computational Model Middleware

5
Using XSLT to target XML to different
Wireless Mobile Devices

WML
XSLT for WAP
<?xml version=‘1.0’?>
<response id=“Result”>
<class
ECE/CS4984 cHTML
XSLT
XSLT for i-mode
</class> Engine
<price>
Invaluable
</price> PDA-
specific
</response> XSLT for PDA (XHTML)

ECE/CS 4984, Spring 2003 11 Client-Server Computational Model Middleware

SOAP for Invoking Web Services


• SOAP (Small Object Access Protocol) is a standard for invoking
XML web services through remote procedure calls over HTTP
• Embraced by Microsoft .NET technology
! .NET Compact Frame implements SOAP 1.1 to allow smart devices
to establish connections and move data to other devices
• To make a method call to a web service, a client first learns the service
interface via the server’s WSDL document to know information such
as:
! The name of the method to be invoked
! The namespace URI (Universal Resource Id) for the method name
" A namespace is simply a unique string to fully qualify XML
element and attribute names
! The parameter names and their data types
! The SOAPAction – to be put in the HTTP header that the client
sends when it invokes the service
! The URL at which the service is running
• The client then sends a request to the URL where the service is
running in a SOAP message in XML format for the RPC

ECE/CS 4984, Spring 2003 12 Client-Server Computational Model Middleware

6
Accessing Web Services

(XSD: XML Schema Definition)

From http://www.learnxmlws.com/tutors/wsdl/wsdl.aspx

ECE/CS 4984, Spring 2003 13 Client-Server Computational Model Middleware

WSDL for Defining Web Services (1)


• WSDL is an XML-based language used to define a Web service
and describe how to access methods provided by the service

• Example: WSDL of a service “WeatherService”:


<definitions name ='weatherservice'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<service name='WeatherService' >
……
</service>
</definitions>

! The <definitions> element is the root element of the WSDL document


! Here, we declare the WSDL namespace as the default namespace for
the document so all elements and attributes belong to this
namespace unless they have another namespace prefix
! Each service is defined using a service element

ECE/CS 4984, Spring 2003 14 Client-Server Computational Model Middleware

7
WSDL for Defining Web Services (2)
• Within a service element, you specify the different “ports” on
which this service is accessible
• A port specifies the service URL, For example, if the URL is
http://www.ws/demos/wsdl/devxpert/weatherservice.asp, the
port definition would look like this:

<port name='WeatherSoapPort'
binding='wsdlns:WeatherSoapBinding' >
<soap:address location=
'http://www.ws/demos/wsdl/devxpert/weatherservice.asp' />
</port>

• Each port has a unique name and a binding attribute


• When using SOAP, the port element contains a
<soap:address/> element with the service address URL

ECE/CS 4984, Spring 2003 15 Client-Server Computational Model Middleware

WSDL for Defining Web Services (3)


• To use Web services in a remote procedure call (RPC)
model, WSDL describes the message structures by
using the <message> element
! Each <message> contains zero or more <part> elements.
! A <part> corresponds to a parameter or a return value in the
RPC call
• For example, the GetTemperature method (operation)
would include one input and one ouput messages:
<message name='Weather.GetTemperature'>
<part name='zipcode' type='xsd:string'/>
<part name='celsius' type='xsd:boolean'/>
</message>

<message name='Weather.GetTemperatureResponse'>
<part name='Result' type='xsd:float'/>
</message>
xsd: float is predefined in http://www.w3.org/2001/XMLSchema
ECE/CS 4984, Spring 2003 16 Client-Server Computational Model Middleware

8
WSDL for Defining Web Services (4)
• The WSDL <operation> element is used to specify which
message is the input and which message is the output, e.g.,

<portType name='WeatherSoapPort'>
<operation name='GetTemperature'
parameterOrder='zipcode celsius'>
<input message='wsdlns:Weather.GetTemperature' />
<output message='wsdlns:Weather.GetTemperatureResponse' />
</operation>
<!-- other operations would go here -->
</portType>

• The parameterOrder attribute is optional and may be used to specify a


space-delimited list of part names to indicate the order of parameters
when making the RPC call
• Inside the <operation> you specify <input> and <output> elements.
Each refers to the corresponding message by its fully qualified name,
e.g. wsdlns:Weather.GetTemperature

ECE/CS 4984, Spring 2003 17 Client-Server Computational Model Middleware

WSDL for Defining Web Services (5)


• The WSDL <binding> element is used to bind <port>:
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' >
….
</binding>
• Inside the <binding> element you use a SOAP extension element called
<soap:binding> to specify the transport protocol you’re using (SOAP can
be used over HTTP, SMTP, or possibly any other transport) and the style of
request (rpc and document are the two styles).
• For each operation that this service exposes, a value of the SOAP Action
is specified in the <soap:operation> element. The client must put the
SOAP Action value in the HTTP header when it invokes the service.

<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' >


<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http' />
<operation name='GetTemperature' >
<soap:operation
soapAction='http://tempuri.org/action/Weather.GetTemperature' />
....
</operation>
</binding>
ECE/CS 4984, Spring 2003 18 Client-Server Computational Model Middleware

9
WSDL for Defining Web Services (6)
<binding name='WeatherSoapBinding' type='wsdlns:WeatherSoapPort' >
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http' />
<operation name='GetTemperature' >
<soap:operation
soapAction='http://tempuri.org/action/Weather.GetTemperature' />
<input>
<soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</input>
<output>
<soap:body use='encoded' namespace='http://tempuri.org/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' />
</output>
</operation>
</binding>

• Within the <operation> you add an <input> and an <output> element and use a
<soap:body> element within each to specify how the data is encoded. The URI
http://schemas.xmlsoap.org/soap/encoding/ indicates the SOAP encoding style as
described in the SOAP 1.1 specification.
ECE/CS 4984, Spring 2003 19 Client-Server Computational Model Middleware

Example: WSDL of XMethods: A Delayed


Stock Quote XML Web Service
<service name="net.xmethods.services.stockquote.StockQuoteService">
<documentation>net.xmethods.services.stockquote.StockQuote web
service</documentation>
<port name="net.xmethods.services.stockquote.StockQuotePort"
binding="tns:net.xmethods.services.stockquote.StockQuoteBinding">
<soap:address location="http://66.28.98.121:9090/soap" />
</port>
</service>
<message name="getQuoteResponse1">
<part name="Result" type="xsd:float" />
</message>
<message name="getQuoteRequest1">
<part name="symbol" type="xsd:string" />
</message>
<portType name="net.xmethods.services.stockquote.StockQuotePortType">
<operation name="getQuote" parameterOrder="symbol">
<input message="tns:getQuoteRequest1" />
<output message="tns:getQuoteResponse1" />
</operation>
</portType>

ECE/CS 4984, Spring 2003 20 Client-Server Computational Model Middleware

10
eVC++ Client to Access the Stock Quote
Web Service using PocketSOAP
• Using PocketSOAP, an eVC++ program can access the stock
quote web service from your iPAQ. We first get user input from
an edit box. Then we invoke the RPC with the stock symbol
entered by a SOAP message to the web server. After receiving a
SOAP response returned from the server, we display the stock
price quoted in the list box.
void CLab4Dlg::OnGo()
{
// get the stock symbol entered by the user
symbol->GetWindowText(strSymbol) ;
// create a new SOAP envelop object
CoCreateInstance(__uuidof(CoEnvelope),NULL,
CLSCTX_INPROC, __uuidof(ISOAPEnvelope), (void **)&penv ) ;
// Set method name and put in the unique namespace of the method
penv->put_MethodName ( CComBSTR(OLESTR("getQuote")) ) ;
penv->put_URI ( CComBSTR(OLESTR("urn:xmethods-delayed-quotes")) ) ;

ECE/CS 4984, Spring 2003 21 Client-Server Computational Model Middleware

eVC++ Client to Access the Stock Quote


Web Service using PocketSOAP (cont.)
// create and set method parameter: symbol is the name and strSymbol is the content
penv->get_Parameters(&params) ;
params->Create (
CComBSTR(OLESTR("symbol")),CComVariant(strSymbol),NULL,NULL,NULL,NULL ));
// create a HTTP transport object and specify the SOAP Action in the HTTP header
CComPtr<IHTTPTransportAdv> pt ;
pt.CoCreateInstance( __uuidof(HTTPTransport) ) ;
pt->put_SOAPAction( CComBSTR(OLESTR("urn:xmethods-delayed-
quotes#getQuote"))) ;
// send the SOAP request to the service address URL
pt->Send ( CComBSTR(OLESTR("http://66.28.98.121:9090/soap")),req );
// parse the SOAP response message and get the returned value
penv->Parse(CComVariant(pt), NULL) ; penv->get_Parameters(&params) ;
CComPtr<ISOAPNode> prm ; params->get_Item(0, &prm) ;
CComVariant resVal ; prm->get_Value(&resVal) ;
// display the result in the list box
resList->InsertString(0, strSymbol + resVal.bstrVal ); }
ECE/CS 4984, Spring 2003 22 Client-Server Computational Model Middleware

11
J2ME Client to Access the Stock Quote
Web Service using kSOAP
import javax.microedition.midlet.*; import javax.microedition.lcdui.*;
import java.io.*; import javax.microedition.io.*;
import org.ksoap.*; import org.ksoap.transport.*;
public class StockQuote extends MIDlet implements CommandListener {
Form mainForm = new Form ("StockQuotes");
TextField symbolField = new TextField ("Symbol", "IBM", 5, TextField.ANY);
StringItem resultItem = new StringItem ("", ""); /* label followed by content */
Command getCommand = new Command (“Go", Command.SCREEN, 1);
public StockQuote () {
mainForm.append (symbolField);
mainForm.append (resultItem);
mainForm.addCommand (getCommand);
mainForm.setCommandListener (this); }

ECE/CS 4984, Spring 2003 23 Client-Server Computational Model Middleware

J2ME Example – A Stock Quote


client using kSOAP (cont.)
public void startApp () {Display.getDisplay (this).setCurrent (mainForm); }
public void pauseApp () { }
public void destroyApp (boolean unconditional) { }
public void commandAction (Command c, Displayable d) { /* On Go */
try {
String symbol = symbolField.getString ();
resultItem.setLabel (symbol);
// compose a SOAP object with the method name and namespace specified
SoapObject rpc = new SoapObject("urn:xmethods-delayed-quotes", "getQuote");
rpc.addProperty ("symbol", symbol); // parameter name and content
resultItem.setText ("“ + new HttpTransport("http://66.28.98.121:9090/soap",
"urn:xmethods-delayed-quotes#getQuote").call (rpc));
} catch (Exception e) { e.printStackTrace (); } }}

ECE/CS 4984, Spring 2003 24 Client-Server Computational Model Middleware

12
Dealing with Device Heterogeneity using
Microsoft’s Mobile Internet Toolkit (MIT)
• Microsoft Mobile Internet Toolkit contains server-side
technology that enables a server (or server-side agent) to
deliver content to a wide variety of mobile devices
! Only a single web service implementation is required to be
developed at the server side using MIT in Visual Studio .NET to deal
with device heterogeneity
! The GUI application can be built with “drag and drop” and
Application Wizards in Visual Studio .NET
• Depending on the client connecting to the web service, MIT can
alter its page rendering accordingly to device types for which
their associated “device adaptors” exist, including
! Internet Explorer (IE): XML to HTML
! Pocket PC IE: XML to HTML
! Pocket PC client developed based on .NET CF: XML/SOAP
! WAP: XML to WML (WAP 1.0) or XHTML (WAP 2.0)
! i-mode: XML to cHTML

ECE/CS 4984, Spring 2003 25 Client-Server Computational Model Middleware

Microsoft’s Mobile Internet Toolkit (MIT)


in Visual Studio .NET (cont.)
• The base MIT distribution
currently does not support Web service
device adaptors for Palm OS Developed
or J2ME-enabled mobile Using MIT
devices:
! Requiring a device adaptor
to be created and defined at
Predefined Predefined Predefined New XML
the server end, e.g., asking Adaptor for Adaptor for Adaptor for Adaptor for
the server to output XML WAP i-mode iPAQ IE J2ME

! Requiring a client code that WML cHTML HTML XML


understands the output
format, e.g., J2ME+kXML for New client
code for
J2ME-enabled devices J2ME

ECE/CS 4984, Spring 2003 26 Client-Server Computational Model Middleware

13
Example: Creating a Web Service Proxy
using MIT in Visual Studio .NET (1)
• Here we use MIT to create a
mobile web application that
serves as a “server-side proxy”
located between a web service
and various heterogeneous
mobile devices
• A Mobile Web Form “form1” is
created using drag and drop for
accepting the user input
• The stock symbol entered is sent
to a stock quote web service
• The stock value returned is
displayed in another Mobile Web
Form “form2.”

ECE/CS 4984, Spring 2003 27 Client-Server Computational Model Middleware

Example: Creating a Web Service Proxy


using MIT in Visual Studio .NET (2)
• MIT will automatically create a C# (pronounced as C Sharp) proxy
class to refer to a XML web service after you add a web reference
to the WSDL file of that web service
! WSDL can be found with the help of a UDDI web service registry
! UDDI (Universal, Description, Discovery and Integration) is a
standard for publishing and inquiring web services with client APIs

• For example, if the web reference added is the WSDL of the stock quote
web service provided xmethods.net at the following URL:

http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl

then the following C# class will be created by MIT to refer to the stock
quote web service:

net.xmethods.services.netxmethodsservicesstockquoteStockQuoteService

! Note that net.xmethods.services.stockquote.StockQuoteService is


the service name advertised in the WSDL file
ECE/CS 4984, Spring 2003 28 Client-Server Computational Model Middleware

14
Example: Creating a Web Service Proxy
using MIT in Visual Studio .NET (3)
public class MobileWebForm1 : System.Web.UI.MobileControls.MobilePage
{
protected System.Web.UI.MobileControls.TextBox TextBox1;
protected System.Web.UI.MobileControls.Command Command1;
protected System.Web.UI.MobileControls.Form Form2;
protected System.Web.UI.MobileControls.Label Label1;
protected System.Web.UI.MobileControls.Form Form1;

private void Command1_Click(object sender, System.EventArgs e)


// This part you will need to fill in yourself
{
ActiveForm = Form2; // ActiveForm is a predefined object to point to the active form
net.xmethods.services.netxmethodsservicesstockquoteStockQuoteService stk =
new net.xmethods.services.netxmethodsservicesstockquoteStockQuoteService();
string ticker = TextBox1.Text; // get the symbol entered by the user
Single price = (Single) stk.getQuote(ticker); // invoke the getQuote method
if (price >0) { Label1.Text = price.ToString(); } // display the price returned
else { Label1.Text = "Invalid Symbol"; }
}}

ECE/CS 4984, Spring 2003 29 Client-Server Computational Model Middleware

Internet Explorer Web Service Access


<html>
<body>
<form id="Form1" name="Form1" method="post"
action="mobilewebform1.aspx?__ufps=635185">
<input type="hidden" name="__EVENTTARGET"
value="">
<input type="hidden" name="__EVENTARGUMENT"
From IE on iPAQ value="">
<script language=javascript>
function __doPostBack(target, argument){
var theform = document.Form1
theform.__EVENTTARGET.value = target
theform.__EVENTARGUMENT.value = argument
theform.submit()
}
</script>
<input name="TextBox1"/><br>
<input name="Command1" type="submit" value="Get
From IE on Quote"/>
Windows 2000 </form>
</body>
</html>
ECE/CS 4984, Spring 2003 30 Client-Server Computational Model Middleware

15
WAP-Device Web Service Access
<?xml version='1.0'?>
<!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.1//EN'
'http://www.wapforum.org/DTD/wml_1.1.xml'>
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0" />
</head>
<card>
<onevent type="onenterforward">
<refresh>
<setvar name="TextBox1" value="" />
</refresh>
</onevent>
<do type="accept" label="Go"><go
href="/StockQuoteProxy/(jx0oiiqq22z1vm450ucv1zfb)/mobilew
ebform1.aspx" method="post">
<postfield name="__EVENTTARGET" value="Command1" />
<postfield name="TextBox1" value="$(TextBox1)" />
</go>
</do>
<p><input name="TextBox1" />
</p></card>
</wml>
ECE/CS 4984, Spring 2003 31 Client-Server Computational Model Middleware

I-mode Device Web Access


• There are more than 32
million wireless internet
users in Japan using NTT-
DoCoMo’s i-mode service
• The source is in cHTML
format
• Some DoCoMo handsets
already include a Java virtual
machine. The NTT-DoCoMo
503i now includes a KVM to
enable the downloading of
JAVA applets (for gaming,
etc.)

ECE/CS 4984, Spring 2003 32 Client-Server Computational Model Middleware

16

You might also like