CS8651 Notes 005-5 Edubuzz360
CS8651 Notes 005-5 Edubuzz360
com
The AJAX Control Toolkit contains more than 30 controls that enable you to easily create rich,
interactive web pages.
Advantages of AJAX
Reduce the traffic travels between the client and the server.
Response time is faster so increases performance and speed.
You can use JSON (JavaScript Object Notation) which is alternative to XML.
2. JSON is key value pair and works like an array.
You can use Firefox browser with an add-on called as Firebug to debug all Ajax
calls.
Ready Open source JavaScript libraries available for use – JQuery, Prototype,
Scriptaculous, etc..
AJAX communicates over HTTP Protocol.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
For years, programming with the XMLHttpRequest object has been the most
commonly used approach for communicating with the server from client-side script.
The complexities involved in coding those types of applications scared away a lot of
developers. To assist, the overall scripting model in ASP.NET 2.0 was significantly
enhanced to introduce the idea of script callbacks—a way for server controls to
communicate with client-side scripts between callbacks. This model was powerful
because it offered access to the state of all the controls on the page during a callback.
Unfortunately, many developers found the model difficult to work with, and
numerous concerns were raised. The lack of support for passing complex types
as parameters to the server (only strings were allowed) made the prototype too rigid
and exposed its limitations. Developers began to look elsewhere for solutions.
In an effort to address these concerns, members of the ASP.NET team began work on
a communication library built on top of the callbacks. The primary objective of the
library was to simplify the use of callbacks and to provide a rich set of APIs for
enabling the exchange of complex and simple types between the server and client.
From this library came a control called the RefreshPanel. The purpose of the
RefreshPanel was to offer a server control that refreshed the contents of a page
without a page refresh. Out of this hard work, the UpdatePanel emerged, with deeper
integration into the page lifecycle and a more transparent footprint on the page.
NOTE
A callback is a piece of code that is passed in as a parameter or argument to other code. The
other piece of code can call the callback code (usually a function) at any time, even
numerous times, in response to some processing.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
The XMLHttpRequest object is used to exchange data with a server behind the
scenes.
Method Description
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Property Description
XML Soap
6.
SOAP stands for Simple Object Access Protocol
SOAP is an application communication protocol
SOAP is a format for sending and receiving messages
SOAP is platform independent
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Why SOAP?
The best way to communicate between applications is over HTTP, because HTTP is
supported by all Internet browsers and servers. SOAP was created to accomplish this.
targetNamespace="http://com/ibm/was/wssample/echo/",
portName="EchoServicePort")
public class EchoServicePortTypeImpl implements EchoServicePortType {
public EchoServicePortTypeImpl() {
}
return str;
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
}
/** This is a sample EchoServicePortType.java service interface */
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.*;
@WebService(name = "EchoServicePortType",
targetNamespace =
"http://com/ibm/was/wssample/echo/",
wsdlLocation="WEB-INF/wsdl/Echo.wsdl")
public interface EchoServicePortType {
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Imports System
Imports System.Web.Services
end class
Using a form and the HTTP POST method, you can put the web service
on your site, like this:
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
<form action='tempconvert.asmx/FahrenheitToCelsius'
method="post" target="_blank">
<table>
<tr>
<td>Fahrenheit to Celsius:</td>
<td>
<input class="frmInput" type="text" size="30" name="Fahrenhei
t">
</td>
</tr>
<tr>
<td></td>
<td align="right">
<input type="submit" value="Submit" class="button">
</td>
</tr>
</table>
</form>
<form action='tempconvert.asmx/CelsiusToFahrenheit'
method="post" target="_blank">
<table>
<tr>
<td>Celsius to Fahrenheit:</td>
<td>
<input class="frmInput" type="text" size="30" name="Celsius">
</td>
</tr>
<tr>
<td></td>
<td align="right">
<input type="submit" value="Submit" class="button">
</td>
</tr>
</table>
</form>
http://www.example.com/xml/tempconvert.asmx
Discover an example for web service registry along with its functions.
Web Services Discovery provides access to software systems over the Internet using
standard protocols. In the most basic scenario there is a Web Service Provider that
9. publishes a service and a Web Service Consumer that uses this service. Web Service
Discovery is the process of finding suitable web services for a given task.[1]
Publishing a web service involves creating a software artifact and making it
accessible to potential consumers. Web service providers augment a service endpoint
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
We should use web services as it comes with various advantages listed below
Re-usability
Once we develop some business logic,we can make it reuse for other applications
Example:
If 10 different applications requires to use our logic
We can expose our logic over a network as a web service
So all the 10 different application can access it from the network.
Interoperability
It provides the freedom for a developers to choose whatever the technology they
want to use for development.
10.
Web services uses a set of standards and protocols and enable us to achieve
interoperability.
Hence applications developed in Java,Mainframe,Ruby or any other technology can
call the web service and use it.
Loosely coupled
Web service exist independent of the other parts of the application that uses it.
So any changes to the application can be made without affecting the web service.
Deployability
It is very easy to deploy the web application as they are deployed over standard
internet technologies.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Features of WSDL
WSDL is an XML-based protocol for information exchange in decentralized and
distributed environments.
WSDL definitions describe how to access a web service and what operations it
will perform.
WSDL is a language for describing how to interface with XML-based services.
WSDL is an integral part of Universal Description, Discovery, and Integration
(UDDI), an XML-based worldwide business registry.
WSDL is the language that UDDI uses.
WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'.
WSDL Usage
WSDL is often used in combination with SOAP and XML Schema to provide
web services over the Internet. A client program connecting to a web service
can read the WSDL to determine what functions are available on the server.
Any special datatypes used are embedded in the WSDL file in the form of XML
Schema. The client can then use SOAP to actually call one of the functions
listed in the WSDL.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
The scope of the Web Services Security Technical Committee is the support of
security mechanisms in the following areas:
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Using XML Signature to provide SOAP message integrity for Web Services
Using XML Encryption to provide SOAP message confidentiality for Web Services
Attaching and/or referencing security tokens in headers of SOAP messages. Options include:
Username token
SAML
XrML
Kerberos
X.509
Carrying security information for potentially multiple, designated actors
Associating signatures with security tokens
Each of the security mechanisms will use implementation and language neutral XML formats
defined in XML Schema.
15. Th the JAX-RPC technology and describes its client and server programming
models. JAX-RPC hides the complexity of underlying protocols and message-level
processing from application developers crafting Web services using the Java 2
platform. The API combines XML with Remote Procedure Call (RPC), which is a
mechanism enabling clients to execute procedures on distributed or remote systems,
so that developers can build Web services and clients. The JAX-RPC remote
procedure calls are represented by an XML infoset and they are carried over a
network transport. While the JAX-RPC APIs rely on a XML-based protocol and a
network transport, the APIs themselves are independent of a specific protocol or
transport. The current JAX-RPC implementation relies on the SOAP 1.1 protocol and
HTTP 1.1 network transport.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Solving customer-driven need to remove barriers to allow for rapid participation in the
global Internet
economy
Describing services and business processes programmatically in a single, open, and
secure environment
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Define WSDL.
WSDL stands for Web Services Description Language. It is the standard
format for describing a web service. WSDL was developed jointly by Microsoft
and IBM.
Features of WSDL
WSDL is an XML-based protocol for information exchange in decentralized and
distributed environments.
WSDL definitions describe how to access a web service and what operations it
will perform.
WSDL is a language for describing how to interface with XML-based services.
WSDL is an integral part of Universal Description, Discovery, and Integration
20.
(UDDI), an XML-based worldwide business registry.
WSDL is the language that UDDI uses.
WSDL is pronounced as 'wiz-dull' and spelled out as 'W-S-D-L'.
WSDL Usage
WSDL is often used in combination with SOAP and XML Schema to provide
web services over the Internet. A client program connecting to a web service
can read the WSDL to determine what functions are available on the server.
Any special datatypes used are embedded in the WSDL file in the form of XML
Schema. The client can then use SOAP to actually call one of the functions
listed in the WSDL.
PART-B
(i) Describe in detail about the AJAX architecture.
1.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Remote procedure calls support process oriented and thread oriented models.
The internal message passing mechanism of RPC is hidden from the user.
The effort to re-write and re-develop the code is minimum in remote procedure
calls.
Remote procedure calls can be used in distributed environment as well as the
local environment.
Many of the protocol layers are omitted by RPC to improve performance.
JAX-RPC stands for Java API for XML-based RPC. It's an API for building
Web services and clients that used remote procedure calls (RPC) and XML.
Often used in a distributed client/server model, an RPC mechanism enables
clients to execute procedures on other systems.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Web Consortium (W3C): HTTP, SOAP, and the Web Service Description
Language (WSDL). WSDL specifies an XML format for describing a
service as a set of endpoints operating on messages.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Run jar and wsdeploy to create a Web Archive (WAR) file converter.war
Name must match urlPatternBase value
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
jaxrpc-ri.xml: Defines the various end points for referencing a Web service.
wscompile: The wscompile tool generates stubs, and WSDL files used in JAX-
RPC clients and
services. The tool reads as input a configuration file and either a WSDL file or an
RMI interface
that defines the service.
wsdeploy: Reads a WAR file (something like Jar file) and the jaxrpc-ri.xml file
and then
generates another WAR file that is ready for deployment
Write service endpoint interface
May need to write additional classes representing data structures
Write class implementing the interface
Compile classes
Create configuration files and run JWSDP tools to create web service
Deploy web service to Tomcat
Just copy converter.war to Tomcat webapps directory
May need to use Manager app to deploy
Enter converter.war in “WAR or Directory URL” text box
Testing success:
Visit http://localhost:8080/converter/currency
The architecture of web service interacts among three roles: service provider,
service requester, and service registry. The interaction involves the three
operations: publish, find, and bind. These operations and roles act upon
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
the web services artifacts. The web service artifacts are the web service
software module and its description.
The following figure illustrates the operations, roles, and their interaction.
o Service Provider
o Service Requestor
o Service Registry
Service Provider
Service Requestor
Service requestor is the application that is looking for and invoking or initiating
an interaction with a service. The browser plays the requester role, driven by a
consumer or a program without a user interface.
Service Registry
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Service requestors find service and obtain binding information for services during
development.
Find: In the find operation, the service requestor retrieves the service description
directly. It can be involved in two different lifecycle phases for the service
requestor:
o Service
o Service Registry
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
<definitions>
<message name="TutorialRequest">
<part name="TutorialID" type="xsd:string"/>
</message>
<message name="TutorialResponse">
<part name="TutorialName" type="xsd:string"/>
</message>
<portType name="Tutorial_PortType">
<operation name="Tutorial">
<input message="tns:TutorialRequest"/>
<output message="tns:TutorialResponse"/>
</operation>
</portType>
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encodi
ng/"
namespace="urn:examples:Tutorialservice"
use="encoded"/>
</output>
</operation>
</binding>
</definitions>
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
XML Soap
SOAP stands for Simple Object Access Protocol
SOAP is an application communication protocol
SOAP is a format for sending and receiving messages
SOAP is platform independent
SOAP is based on XML
SOAP is a W3C recommendation
8.
Why SOAP?
It is important for web applications to be able to communicate over the
Internet.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Syntax Rules
Here are some important syntax rules:
SOAP - Encoding
SOAP includes a built-in set of rules for encoding data types. It enables the
SOAP message to indicate specific data types, such as integers, floats,
doubles, or arrays.
SOAP data types are divided into two broad categories − scalar types and
compound types.
Scalar types contain exactly one value such as a last name, price, or product
description.
Compound types contain multiple values such as a purchase order or a list of
stock quotes.
Compound types are further subdivided into arrays and structs.
Compound Types
SOAP arrays have a very specific set of rules, which require that you specify
both the element type and array size. SOAP also supports multidimensional
arrays, but not all SOAP implementations support multidimensional
functionality.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
To create an array, you must specify it as an xsi:type of array. The array must
also include an arrayType attribute. This attribute is required to specify the
data type for the contained elements and the dimension(s) of the array.
For example, the following attribute specifies an array of 10 double values −
arrayType = "xsd:double[10]"
In contrast, the following attribute specifies a two-dimensional array of strings
−
arrayType = "xsd:string[5,5]"
Here is a sample SOAP response with an array of double values −
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-
envelope"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getPriceListResponse
xmlns:ns1 = "urn:examples:pricelistservice"
SOAP-ENV:encodingStyle =
"http://www.w3.org/2001/12/soap-encoding">
<return xmlns:ns2 =
"http://www.w3.org/2001/09/soap-encoding"
xsi:type = "ns2:Array" ns2:arrayType =
"xsd:double[2]">
<item xsi:type = "xsd:double">54.99</item>
<item xsi:type = "xsd:double">19.99</item>
</return>
</ns1:getPriceListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Structs contain multiple values, but each element is specified with a unique
accessor element. For example, consider an item within a product catalog. In
this case, the struct might contain a product SKU, product name, description,
and price. Here is how such a struct would be represented in a SOAP message
−
<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-
envelope"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getProductResponse
xmlns:ns1 = "urn:examples:productservice"
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
SOAP-ENV:encodingStyle =
"http://www.w3.org/2001/12/soap-encoding">
Analyze the various steps in database driven web service with some
example.
The Database Web services technology is a database approach to Web services. It works in the
following two directions:
9.
Accessing database resources as a Web service
Consuming external Web services from the database
Oracle Database can access Web services through PL/SQL packages and Java classes deployed
within the database. Turning Oracle Database into a Web service provider leverages investment in
Java stored procedures, PL/SQL packages, predefined SQL queries, and data manipulation
language (DML). Conversely, consuming external Web services from the database, together with
integration with the SQL engine, enables Enterprise Information Integration.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
You can call into the database from a Web service, using the database as a service provider. This
enables you to leverage existing or new SQL, PL/SQL, Java stored procedures, or Java classes
within Oracle Database. You can access and manipulate database tables from a Web service
client.
Illustrate on web services for writing web service client along with
the description of WSDL.
Typically, you retrieve the WSDL directly from a web service provider using the wsimport tool.
The wsimport tool then generates the corresponding Java source code for the interface described by
the WSDL. The Java compiler, javac, is then called to compile the source into class files. The
programming code uses the generated classes to access the web service.
package fromjava.client;
import com.sun.xml.ws.Closeable;
import java.rmi.RemoteException;
number1 = -10;
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
This file specifies two positive integers that are to be added by the web service, passes the integers to
the web service and gets the results from the web service via the port.addNumbers method, and
prints the results to the screen. It then specifies a negative number to be added, gets the results (which
should be an exception), and prints the results (the exception) to the screen.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
2. Install JWSDP 2.0 & Tomcat 5.0 for JWSDP (based upon Tomcat 5.0.19
that implements
the Java Server Pages 2.0 and Java Servlet 2.4 specifications)
C:\Sun\jwsdp-2.0\saaj\lib
C:\Sun\tomcat50-jwsdp\saaj\lib
tutorial.home=C:
tutorial.install=${tutorial.home}
username=hxu
password=12345
where "hxu" and "12345" are the username and password for the
Tomcat server.
7. Build server:
cd C:\examples\jaxrpc\helloservice
ant build
Deploy server:
ant deploy
http://localhost:8080/hello-jaxrpc/hello?WSDL
You should get the following display.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
8. Build client:
cd C:\examples\jaxrpc\dynamicproxy
ant build
Run client:
ant run
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
XML Soap
SOAP stands for Simple Object Access Protocol
SOAP is an application communication protocol
SOAP is a format for sending and receiving messages
SOAP is platform independent
SOAP is based on XML
SOAP is a W3C recommendation
Why SOAP?
Syntax Rules
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
This means that both the web page and the XML file it tries to load,
must be located on the same server.
If you want to use the example above on one of your own web pages,
the XML files you load must be located on your own server.
Example
if (window.XMLHttpRequest) {
// code for modern browsers
xmlhttp = new XMLHttpRequest();
} else {
// code for old IE browsers
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
JAX-WS API is inbuilt in JDK, so you don't need to load any extra jar file for it.
Let's see a simple example of JAX-WS example in RPC style.
1. HelloWorld.java
2. HelloWorldImpl.java
3. Publisher.java
4. HelloWorldClient.java
The first 3 files are created for server side and 1 application for client side.
1. package com.javatpoint;
2. import javax.jws.WebMethod;
3. import javax.jws.WebService;
4. import javax.jws.soap.SOAPBinding;
5. import javax.jws.soap.SOAPBinding.Style;
6. //Service Endpoint Interface
7. @WebService
8. @SOAPBinding(style = Style.RPC)
9. public interface HelloWorld{
10. @WebMethod String getHelloWorldAsString(String name);
11. }
File: HelloWorldImpl.java
1. package com.javatpoint;
2. import javax.jws.WebService;
3. //Service Implementation
4. @WebService(endpointInterface = "com.javatpoint.HelloWorld")
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
File: Publisher.java
1. package com.javatpoint;
2. import javax.xml.ws.Endpoint;
3. //Endpoint publisher
4. public class HelloWorldPublisher{
5. public static void main(String[] args) {
6. Endpoint.publish("http://localhost:7779/ws/hello", new HelloWorldIm
pl());
7. }
8. }
1. http://localhost:7779/ws/hello?wsdl
1. package com.javatpoint;
2. import java.net.URL;
3. import javax.xml.namespace.QName;
4. import javax.xml.ws.Service;
5. public class HelloWorldClient{
6. public static void main(String[] args) throws Exception {
7. URL url = new URL("http://localhost:7779/ws/hello?wsdl");
8.
9. //1st argument service URI, refer to wsdl document above
10. //2nd argument is service name, refer to wsdl document above
11. QName qname = new QName("http://javatpoint.com/", "HelloWorld
ImplService");
12. Service service = Service.create(url, qname);
13. HelloWorld hello = service.getPort(HelloWorld.class);
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Output:
• For transfer between client and server in a SOAP message, we encode them in
XML.
SOAP Encoding is an extension of the SOAP framework specification that defines how a
data value should be encoded in an XML format. SOAP Data Model is defined as an
adjunct in SOAP 1.2 specification.
SOAP encoding offers the following rules to convert any data value defined in SOAP
data model into XML format. Converting a data value into XML format is called
serialization or encoding.
Rule 1. A simple value node with a labeled inbound edge will be serialized into a single
XML element with the edge's label as the element's name and node value as the
element's text content.
Rule 2. When serializing a node into an XML element, an "xsi:type" attribute can be
added to specify the value type of this note. For more information on "xsi:type", see the
other sections in this book.
Rule 3. A compound value node with labeled outbound edges, a data structure, will be
serialized into a single XML element with child elements. One outbound edge will be
serialized into one child element with element's name equal to the edge's label. The
13. order of child elements is not significant.
Rule 4. A compound value node with non-labeled outbound edges, a data array, will be
serialized into a single XML element with child elements. One outbound edge will be
serialized into one child element with element's name equal to any label as long as it's
the same for all child elements. The order of child elements signifies the position values
of outbound edges.
Rule 5. When serializing an array, an "enc:itemType" attribute can be added to specify
the value type of its sub nodes, and an "enc:arraySize" attribute can be added to specify
the number of values in the array.
What Is JAX-RPC?
JAX-RPC stands for Java API for XML-based RPC. It's an API for building
Web services and clients that used remote procedure calls (RPC) and XML.
Often used in a distributed client/server model, an RPC mechanism enables
clients to execute procedures on other systems.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Types– a container for data type definitions using some type system
(such as XSD).
Message– an abstract, typed definition of the data being
communicated.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
This example uses a fixed XML format instead of the SOAP encoding (for
an example using the SOAP encoding, see Example 4).
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<schema targetNamespace="http://example.com/stockquote.xsd"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>
<element name="tickerSymbol" type="string"/>
</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price" type="float"/>
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
</all>
</complexType>
</element>
</schema>
</types>
<message name="GetLastTradePriceInput">
<part name="body" element="xsd1:TradePriceRequest"/>
</message>
<message name="GetLastTradePriceOutput">
<part name="body" element="xsd1:TradePrice"/>
</message>
<portType name="StockQuotePortType">
<operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput"/>
<output message="tns:GetLastTradePriceOutput"/>
</operation>
</portType>
<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://example.com/stockquote"/>
</port>
</service>
</definitions>
PAR
T–C
Q.No Questions
Create an XML HttpRequest to retrieve data from an XML file and
display the data in an HTML table. The data to be retrieved is a
collection of stationary items stored in an XML file.
1.
The XML Document Used
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
This example loops through each <CD> element, and displays the
values of the <ARTIST> and the <TITLE> elements in an HTML table:
Example
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse:collapse;
}
th, td {
padding: 5px;
}
</style>
</head>
<body>
<table id="demo"></table>
<script>
function loadXMLDoc() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xmlhttp.open("GET", "cd_catalog.xml", true);
xmlhttp.send();
}
function myFunction(xml) {
var i;
var xmlDoc = xml.responseXML;
var table="<tr><th>Artist</th><th>Title</th></tr>";
var x = xmlDoc.getElementsByTagName("CD");
for (i = 0; i <x.length; i++) {
table += "<tr><td>" +
x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValu
e +
"</td><td>" +
x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue
+
"</td></tr>";
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
}
document.getElementById("demo").innerHTML = table;
}
</script>
</body>
</html>
OUTPUT
Artist Title
Bob Dylan Empire Burlesque
Bonnie Tyler Hide your heart
Dolly Parton Greatest Hits
Gary Moore Still got the blues
Eros Ramazzotti Eros
Bee Gees One night only
Dr.Hook Sylvias Mother
Summarize Ajax Client server architecture in detail.
What is AJAX?
AJAX = Asynchronous JavaScript And XML.
2. A browser built-in XMLHttpRequest object (to request data from a web server)
JavaScript and HTML DOM (to display or use the data)
AJAX is a misleading name. AJAX applications might use XML to transport data, but it
is equally common to transport data as plain text or JSON text.
AJAX allows web pages to be updated asynchronously by exchanging data with a web
server behind the scenes. This means that it is possible to update parts of a web page,
without reloading the whole page.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Give the basic structure of a WSDL and show how they are used to
create, publish, test and describe web services.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
definitions
Contains the definition of one or more services. JDeveloper
generates the following attribute declarations for this section:
name is optional.
targetNamespace is the logical namespace for information
about this service. WSDL documents can import other
WSDL documents, and setting targetNamespace to a
unique value ensures that the namespaces do not clash.
xmlns is the default namespace of the WSDL document,
and it is set to http://schemas.xmlsoap.org/wsdl/.
All the WSDL elements, such
as <definitions>, <types> and <message> reside in this
namespace.
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
Ajax applications add a layer between the client and the server to
manage communication between the two (Fig. 15.2). When the user
interacts with the page, the client creates an XMLHttpRequest object
to manage a request (Step 1).
The XMLHttpRequest object sends the request to the server (Step 2)
and awaits the response.
The requests are asynchronous, so the user can continue interacting
with the application on the client-side while the server processes the
https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
https://play.google.com/store/apps/details?id=com.sss.edubuzz360