Question Paper Solutions: Unit 1 Introduction, Web Services
Question Paper Solutions: Unit 1 Introduction, Web Services
Question Paper Solutions: Unit 1 Introduction, Web Services
0 10CS666
Introduction,Web Services
1. Write short notes on :
a. Software as services (Soas)
b. Social networking
c. Folksonomies (June/July 11)(9 marks)
Ans :
This approach to application delivery is part of the utility computing model where all of
the technology is in the "cloud" accessed over the Internet as a service.
Advantages
Folksonomies became popular on the Web around 2004 as part of social software
applications such as social bookmarking and photograph annotation. Tagging, which is
one of the defining characteristics of Web 2.0 services, allows users to collectively
classify and find information. Some websites include tag clouds as a way to visualize tags
in a folksonomy.
2. Define web services. What are the building blocks of a SOAP message ? (June/July
11) (5 marks)
It relies on Extensible Markup Language (XML) for its message format, and usually
relies on other Application Layer protocols, most notably Remote Procedure Call (RPC)
and Hypertext Transfer Protocol (HTTP), for message negotiation and transmission.
SOAP can form the foundation layer of a web services protocol stack, providing a basic
messaging framework upon which web services can be built.
This XML based protocol consists of three parts: an envelope, which defines what is in
the message and how to process it, a set of encoding rules for expressing instances of
application-defined datatypes, and a convention for representing procedure calls and
responses.
As an example of how SOAP procedures can be used, a SOAP message could be sent to a
web-service-enabled web site, for example, a real-estate price database, with the
parameters needed for a search.
The site would then return an XML-formatted document with the resulting data, e.g.,
prices, location, features. Because the data is returned in a standardized machine-
parseable format, it could then be integrated directly into a third-party web site or
application.
The SOAP architecture consists of several layers of specifications: for message format,
Message Exchange Patterns (MEP), underlying transport protocol bindings, message
processing models, and protocol extensibility.
SOAP is the successor of XML-RPC, though it borrows its transport and interaction
neutrality and the envelope/header/body from elsewhere (probably from WDDX).
3. What is JSON? How do you convert a string to JSON object? Consider the
following information about a student in an engineering college affiliated to vtu. The
information includes USN, name of the college, branch, year of joining and email id.
a. Create an object literal
b. Write a JSON code for the above information. (June/July 11) (6 marks)
UNIT 2
Ans :
Accessibility: Consider who your primary and secondary users will be and
how they most likely will access your Ajax application. Don't program
yourself into a corner so that an unexpected new audience will be completely
locked out. Will your users be using older browsers or special software? Make
sure you know ahead of time and plan for it.
Avoid entire page downloads: All server communication after the initial
page download should be managed by the Ajax engine. Don't ruin the user
experience by downloading small amounts of data in one place, but reloading
the entire page in others.
User first: Design the Ajax application with the users in mind before anything
else. Try to make the common use cases easy to accomplish and don't be
caught up with how you're going to fit in advertising or cool effects.
2. Draw the diagram for AJAX application model and traditional web application
model and compare them. (June/July 11) (8 marks)
Ans :
The classic web application model works like this: Most user actions in the interface
trigger an HTTP request back to a web server.
The server does some processing —retrieving data, crunching numbers, talking to various
legacy systems —and then returns an HTML page to the client.
It’s a model adapted from the Web’s original use as a hypertext medium, but as fans of
The Elements of User Experience know, what makes the Web good for hypertext doesn’t
necessarily make it good for software applications.
This approach makes a lot of technical sense, but it doesn’t make for a great user
experience. While the server is doing its thing, what’s the user doing? That’s right,
waiting.
And at every step in a task, the user waits some more. Obviously, if we were designing
the Web from scratch for applications, we wouldn’t make users wait around.
Once an interface is loaded, why should the user interaction come to a halt every time
the application needs something from the server? In fact, why should the user see the
application go to the server at all?
Ans :
HiddenFrameGET
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Get Customer Data</title>
<?php
//customer ID
$sID = $_GET["id"];
//database information
$sDBServer = "localhost";
$sDBName = "ajax";
$sDBUsername = "root";
$sDBPassword = "";
if($sInfo == '') {
if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
$aValues = mysql_fetch_array($oResult,MYSQL_ASSOC);
$sInfo = $aValues['Name']."<br />".$aValues['Address']."<br />".
$aValues['City']."<br />".$aValues['State']."<br />".
$aValues['Zip']."<br /><br />Phone: ".$aValues['Phone']."<br />".
"<a href=\"mailto:".$aValues['E-mail']."\">".$aValues['E-mail']."</a>";
} else {
$sInfo = "Customer with ID $sID doesn't exist.";
}
}
mysql_close($oLink);
?>
<script type="text/javascript">
window. () {
var divInfoToReturn = document.getElementById("divInfoToReturn");
top.frames["displayFrame"].displayCustomerInfo(divInfoToReturn.innerHTML);
};
</script>
</head>
<body>
<div id="divInfoToReturn"><?php echo $sInfo ?></div>
</body>
</html>
UNIT - 3
Ans :
a) Submission throttling :
If retrieving data from the server is one part of the problem sending data to server
is another.
Seince in AJAX page refreshes needs to be avoided, it is important to know when
to send user data to the server.
One approach that could be taken is to send data to server on every user
interaction. But this results in a lot of requests submitted to the server is a short
period.
In case of submission throttling, the data to be send to the server is buffered on the
client.
This data is then sent to the server at predefined times.
The delay from typing to sending data is fine tuned such that it doent seem lika a
delay to the user.
Then a client side function is invoked that begins buffering the data.
Then a client side function is invoked that begins buffering the data.
It can be sent at a predefined time interval.
This determination depends on the usecase being used.
After the data is sent, the application continous to gather data.
b) Predictive fetch :
In case of traditional web applications, the application reacts only when there is
an interaction.
This is called “fetch on demand”. The user action tells the server what data should
be retrieved.
In the predictive fetch algorithm, the application guesses what the user is going to
do next and retrieves the appropriate data.
Determining the future action of the user is just or guess based on the users
intentions.
For eg: say a user is reading an online article of 3 pages. It can be assumed here
that if the user is reading the 1st page for few seconds, the person will also be
interested in reading the 2nd page.
Hence the 2nd page can be downloaded at the background before the user
explicitly clicks on the ‘Next’.
Therefore when the user clicks on next the n2d page instantaneously appears
reducing the response time.
Similarly the 3rd page can be downloaded when the user reads 2nd page for a few
seconds.
This extra data being downloaded is cached on the client.
Some approach can be applied in emails. If a person starts composing a mail, it is
logical to anticipate that the mail would be sent to someone in the address book so
this can be preloaded and kept.
By using ajax to fetch information related to any possible next step, can overload
the server.
Therefore this algorithm has to be implemented only when it is logical to assume
that information will be requisite to completing the user’s next request
c) Fallback patterns
All the above methods work fine when there is no problem at the server side.
The following problems can occur:
The request might never make it to the server.
An error might occur at the server.
If error occurs on the server like a file not fount or an internal server error , then it
doesn’t make sense to trying again after a few minutes.
Such problems needs an administrator to fix it.
In such a situation all the pending requests are simply cancelled.
This can be done by setting a flag somewhere in the code that says “don’t send
any more request”.
This solution has maximum impact on the periodic refresh pattern.
Try Again
Another option is to silently keep trying for either a specified amount of time or a
particular number of files.
This problem is handled behind the scenes without generally notifying the user.
Unless the ajax functionality is key to the user’s experience, it is not needed to
notify her about the failures.
2. Write down any four XML http request methods along with their parameters
(June/July 11) (4 marks)
Ans :
Ans :
A Web designer can change an IFrame's content without requiring the user to
reload the surrounding page. This capacity is enabled through JavaScript or the
target attribute of an HTML anchor. Web designers use IFrames to embed
Cache control - Whenever repeated calls to the same page all dealt with browser
caching needs to be considered.
Web browsers tend to cache certain resources to improve the speed
with which sites are downloaded and displayed.
This increases the speed on frequently visited web sites.
Caching can be dealt with by including a header with caching
information on any data being sent from the server to the browser.
Cache_Control : no_cache
Expires : Fri, 30 Oct 1998 14:19:41 GMT
This tells the browser not to cache the data coming from the
specific URL. Instead the browser always calls a new version from
the server instead of a saved version from its own cache.
Unit 4
1. Explain factors that influence the flash player (June/July 11) (6 marks)
Ans : Flex is part of the Adobe Flash Platform, which is a set of technologies with Flash
Player at the core.
Flex applications are intended to be deployed to Flash Player, meaning Flash Player
runs all Flex applications.
Flash Player is one of the most ubiquitous pieces of software anywhere. Because all the
computers that have internet will be having some version of Flash Player installed and
some of the mobile devices being Flash – enabled.
The Flex framework is synonymous with the Flex class library and is a collection of
ActionScript classes used by Flex applications.
The Flex framework is written entirely in ActionScript classes, and defines controls,
containers, and managers designed to simplify building rich Internet applications.
The Flex class library.
Ans :
What works for HTML may or may not work for Flex.
Both traditional and Flex applications are n-tiered.
The traditional applications have, at a minimum, a data tier , a business tier and a
presentation tier. Data tier – databases or similar resources.
Business tier – The core business logic. Eg: accept request from client or presentation tier,
query the data tier.Presentation tier – HTML, CSS, JavaScript, JSP or similar documents.
A new tier called Client tier. Client tier – enables clients to offload computation from the
server. It helps in network latency and making for responsive and highly interactive user
interfaces. In case of Traditional web app client tier is state less and non responsive.
The flex app client is stateful, which means that it can make changes to view without
having to make a request to the server.
Ans :
Flex applications deployed on the web works differently than html applications.
Every Flex app deployed on the web utilizes Flash Player as the deployment platform.
Should understand Flash Player to understand Flex. All Flex app use the Flex Frame
work at a minimum to compile the app.
It is Imp to understand the relationship between the Source code files, the complier and
Flash player All Flex App require MXML or Action script class files or both.
Flash Player does not how to interpret MXML or uncompiled Action script class files.
It is necessary to compile the source code files to the .swf format, which flash player can
interpret. A typical Flex application compiles to just one .swf file. Deploy this .swf file to
server and when a requested, it plays back in flash player. Assets can be embedded within
a .swf file or they can be loaded at runtime.
Embedding makes less streamlined downloading experience and
less dynamic app.
The assets are loaded into flash player when requested by the .swf
at runtime.
In this case asset file must be deployed to a valid URL.
4. What is meant by flex framework? Explain any four frameworks. (June/July 11) (5
marks)
Ans : The Flex framework is synonymous with the Flex class library and is a collection of ActionScript
classes used by Flex applications.
The Flex framework is written entirely in ActionScript classes, and defines controls, containers,
and managers designed to simplify building rich Internet applications.
The Flex class library.
UNIT 5
1. Define action script. What are all the ways to include Action script within flex with
examples? (June/July 11) (6 marks)
Ans :
ActionScript is an object-oriented language originally developed by Macromedia
Inc. used primarily for the development of websites and software targeting the Adobe Flash
Player platform, used on Web pages in the form of embedded SWF files.
When you use an MXML tag to create a component instance, it is the equivalent to calling
the component class’s constructor as part of a new statement. For example, the following
MXML tag creates a new button:
<mx:Button id="button" />
That is equivalent to the following piece of ActionScript code:
var button:Button = new Button();
If you assign property values using MXML tag attributes, that’s equivalent to
setting the object properties via ActionScript. For example, the following creates
abuttonand sets thelabel:
<mx:Button id="button" label="Click" />
The following code is the ActionScript equivalent:
For example, the following creates a new class that extendsmx.core.Applicationand creates one
property calledButtonof typemx.controls.Button:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Button id="Button" />
/mx:Application>
The preceding example is essentially the same as the following ActionScript class:
package {
import mx.core.Application;
import mx.controls.Button;
public class Example extends Application {
internal var button:Button;
public function Example() {
super();
button = new Button();
addChild(button);
}
}
}
2. Create a button with the is as button and change the label of button as click, using
MXML and action script. (June/July 11) (4 marks)
Ans :
<?xml version="1.0"?>
<!-- controls\swfloader\FlexApp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
height="200" width="200">
<mx:Script>
<![CDATA[
[Bindable]
public var varOne:String = "This is a public variable.";
</mx:Application>
3. Defines interfaces. List the differences between interfaces and classes. (June/July 11)
(5 marks)
Ans :
4. Explain how action script handles runtime errors. (June/July 11) (5 marks)
Ans : ActionScript 3.0 includes many tools for error handling, including:
Error classes. ActionScript 3.0 includes a broad range of Error classes to expand
the scope of situations that may produce error objects. Each Error class helps
applications handle and respond to specific error conditions, whether they are
related to system errors (like a MemoryError condition), coding errors (like an
ArgumentError condition), networking and communication errors (like a URIError
condition), or other situations. For more information on each class, see Comparing
the Error classes.
Fewer silent failures. In earlier versions of Flash Player, errors were generated and
reported only if you explicitly used the throw statement. For Flash Player 9 and
later and Adobe AIR, native ActionScript methods and properties throw run-time
errors that allow you to handle these exceptions more effectively when they occur,
and then individually react to each exception.
Clear error messages displayed during debugging. When you are using the
debugger version of Flash Player or Adobe AIR, problematic code or situations
will generate robust error messages, which help you easily identify reasons why a
particular block of code fails. This makes fixing errors more efficient. For more
information, seeWorking with the debugger versions of Flash Player and AIR.
Precise errors allow for clear error messages displayed to users at run time. In
previous versions of Flash Player, the FileReference.upload() method returned a
Boolean value of false if the upload() call was unsuccessful, indicating one of five
possible errors. If an error occurs when you call the upload() method in
ActionScript 3.0, you can throw one of four specific errors, which helps you
display more accurate error messages to end users.
Refined error handling. Distinct errors are thrown for many common situations.
For example, in ActionScript 2.0, before a FileReference object has been
populated, the name property has the value null (so, before you can use or display
the name property, you need to ensure that the value is set and not null). In
ActionScript 3.0, if you attempt to access the name property before it has been
populated, Flash Player or AIR throws an IllegalOperationError, which informs
you that the value has not been set, and you can usetry..catch..finally blocks to
handle the error. For more information see Using try..catch..finally statements.
UNIT 6
Ans : The following flow diagram represents the process that is abstracted within the Flex framework
when the addChild() command is made to create and make a visual component visible on the stage, or
when the properties of the component and/or it parent change
2. Differentiate between flash player and flex framework. (June/July 11) (4 marks)
Ans : Flex provides the ability to create a SWF file (flash player files) that runs on the Adobe
Flash Player in any web browser.
Just like the Flash was created to enable animators and illustrators to provide visually
appealing experiences on the web, Flex was design for the same purpose, but Flex is Flash’s
“big brother”, it’s the same “technology” but the way applications are built is different and
allow much more complicated applications to be built by software engineers instead of
animators.
Flex is not a new language (it does use MXML, but that is converted to Actionscript and
most of the hard work is done in Actionscript), it uses Actionscript just like flash does, but it
comes with a lot of extra features, to make more intelligent applications.
b ) <?xml version="1.0"?>
<!-- containers\intro\Panel3Children.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
4. Draw the class diagram of container components. Explain any three of it. (June/July 11)
(6 marks)
Ans : Flex containers are implemented as a hierarchy in an ActionScript class library, as the
following image shows:
Containers provide a hierarchical structure that lets you control the layout characteristics of
child components.
. There are two types of containers: layout and navigator.
Containers have predefined navigation and layout rules, so you do not have to spend time
defining these. Instead, you can concentrate on the information that you deliver, and the
options that you provide for your users, and not worry about implementing all the details of
user action and application response.
Predefined layout rules also offer the advantage that your users soon grow accustomed to
them. That is, by standardizing the rules of user interaction, your users do not have to think
about how to navigate the application, but can instead concentrate on the content that the
application offers.
UNIT 7
Ans : Flex includes a component-based development model that you use to develop your
application and its user interface. You can use the prebuilt visual components included with
Flex, extend components to add new properties and methods, and create components as
required by your application.
Visual components are extremely flexible and provide you with a great deal of control over
the component's appearance, how the component responds to user interactions, the font and
size of any text included in the component, the size of the component in the application, and
many other characteristics.
The characteristics of visual components include the following:
Size - Height and width of a component. All visual components have a default size. You
can use the default size, specify your own size, or let Flex resize a component as part of
laying out your application.
Events - Application or user actions that require a component response. Events include
component creation, mouse actions such as moving the mouse over a component, and
button clicks.
Styles - Characteristics such as font, font size, and text alignment. These are the same
styles that you define and use with Cascading Style Sheets (CSS).
Behaviors - Visible or audible changes to the component triggered by an application or
user action. Examples of behaviors are moving or resizing a component based on a
mouse click.
Skins - Classes that control a visual component's appearance.
2. What is meant by an event ? Write a function call named as display, which display
the message “VTU belgaum” when you click the button using click event of MXML
and Action script. (June/July 11) (5 marks)
Ans :
ActionScript 2.0, you define the event handler within the object receiving the event—
giving the function the name of the event being received. For example, to react to an
"onPress" event for a button named submitButton in ActionScript 2.0, you would use:
<?xml version="1.0"?>
<!-- controls\button\ButtonLabel.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
function display ()
{
mx.controls.Alert.show(“VTU Belgaum”)
}
</mx:Script>
<mx:Button id="button1" label="Hello world!" click=”display();” width="100"/>
</mx:Application>
3. What is meant by data models? Explain with one example, what are the ways you
can do it. (June/July 11) (5 marks)
Ans :
Data binding is the process of tying the data in one object to another object. It
provides a convenient way to pass data between the different layers of the
application.
Data binding requires a source property, a destination property, and a triggering
event that indicates when to copy the data from the source to the destination.
An object dispatches the triggering event when the source property changes.
Adobe Flex provides three ways to specify data binding: the curly braces ({})
syntax in MXML, the <mx:Binding> tag in MXML, and the BindingUtils methods
in ActionScript.
The following example uses the curly braces ({}) syntax to show a Text control
that gets its data from a TextInput control's text property:
<?xml version="1.0"?>
<!-- binding/BasicBinding.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
UNIT 8
Ans :
This category consists of the FileReference API which is native to Flash Player
and allows file upload and download directly within Flex applications .
Every site sits on a Web server. It’s the thing that serves up the page, typically Internet
Information Server (IIS) in the Microsoft world.
b. RSS
RSS (most commonly expanded as Really Simple Syndication) is a family of web feed
formats used to publish frequently updated works—such as blog entries, news headlines,
audio, and video—in a standardized format.[2] An RSS document (which is called a
"feed", "web feed",[3] or "channel") includes full or summarized text, plus metadata such
as publishing dates and authorship. Web feeds benefit publishers by letting them
syndicate content automatically. They benefit readers who want to subscribe to timely
updates from favored websites or to aggregate feeds from many sites into one place. RSS
feeds can be read using software called an "RSS reader", "feed reader", or "aggregator",
which can be web-based, desktop-based, or mobile-device-based. A standardized XML
file format allows the information to be published once and viewed by many different
programs. The user subscribes to a feed by entering into the reader the feed's URI or by
clicking an RSS icon in a web browser that initiates the subscription process. The RSS
reader checks the user's subscribed feeds regularly for new work, downloads any updates
that it finds, and provides a user interface to monitor and read the feeds. RSS allows users
to avoid manually inspecting all of the websites they are interested in, and instead
subscribe to websites such that all new content is pushed onto their browsers when it
becomes available.