Академический Документы
Профессиональный Документы
Культура Документы
QUESTION BANK - 1
1. Write sample WSDL file and explain various parts of it.
WSDL Elements
A WSDL document contains the following elements:
Definition: It is the root element of all WSDL documents. It defines the name
of the web service, declares multiple namespaces used throughout the
remainder of the document, and contains all the service elements described
here.
Data types: The data types to be used in the messages are in the form of XML
schemas.
Port type: It is an abstract set of operations mapped to one or more endpoints, defining the collection of operations for a binding; the collection of
operations, as it is abstract, can be mapped to multiple transports through
various bindings.
Binding: It is the concrete protocol and data formats for the operations and
messages defined for a particular port type.
Documentation: This
element
is
used
to
provide
human-readable
NOTE: WSDL parts are usually generated automatically using web servicesaware tools.
WSDL program.
Let us assume the service provides a single publicly available function,
calledsayHello. This function expects a single string parameter and
returns a single string greeting. For example, if you pass the
parameter world then service function sayHello returns the greeting,
"Hello, world!".
Example
Contents of HelloService.wsdl file:
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</output>
</operation>
</binding>
<service name="Hello_Service">
<documentation>WSDL File for HelloService</documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://www.examples.com/SayHello/" />
</port>
</service>
</definitions>
Example Analysis
Definitions : HelloService
Type : Using built-in data types and they are defined in XMLSchema.
Message :
4. Give Difference between DTD and XSD. Create DTD file Library Book
information and create also well-formed XML file for Library Book
information against this DTD file.
There are many differences between DTD and XSD. The important differences are given
below:
No. DTD
XSD
Definition.
datatypes.
and attributes.
namespace.
child elements.
XSD is extensible.
)
7
)
structure.
structure.
LIBRARY DTD
<!DOCTYPE LIBRARY [
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT
LIBRARY (ARTICLE+)>
BOOK (BOOK NAME, AUTHOR NAME, PUBLICATION, ISDN, YEAR, PRICE)>
BOOK NAME (#PCDATA)>
AUTHOR NAME (#PCDATA)>
BOOK
BOOK
BOOK
BOOK
5. Create web service. It takes user name as parameter and replies with total
number of characters in name. Also write client program.
package Hello;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class HelloWB {
//method 1 to concate strings
@WebMethod(operationName = "add")
public String add(@WebParam(name = "str")
String str) {
String s="Welcome ";
return s+str;
}
//method2 to find length of the string
@WebMethod(operationName = "length")
public int length(@WebParam(name = "str")
String str) {
return (str.length());
}
}
6. Why XML document is used in SOA? Create XSL file for Railway Ticket for
Passengers for displaying it in Browser.
XML
eXtensible Markup Language (XML) has become the de facto standard for describing data to be
exchanged on the Web. As it's name indicates, XML is a markup language. It involves the use of
tags that "mark up" the contents of a document, and in doing so, describe the contents of a
document. An XML tag identifies information in a document, and also identifies the structure of
the information. For example, the following XML markup identifies some information
as bookshelf. The XML markup also describes the structure of bookshelf.
The bookshelf structure includes two subordinate items identified as book. Each book has three
subordinate items identified as title,author, and price.
<bookshelf>
<book>
<title>My Life and Times</title>
<author>Felix Harrison</author>
<price>39.95</price>
</book>
</bookshelf>
Although tags such as <book> and <title> might appear to inherently give meaning to the
information they identify, they really don't. Information tagged with XML tags has meaning only
if people associate a particular meaning with a particular tag. If people (1) agree on the meaning
of a tag, say that the <book> tag is used to identify a book, and that <title>, <author>,
and <price>tags identify the title, author, and price of the book, respectively, and (2) use those
tags consistently, it gives people a way to exchange data. Their applications can send XML
documents to each other, and process the information in those documents, relying on the
commonly understood meanings associated with the XML tags. Applications capable of
interpreting these tags can then process the information according to the meaning of the
information and its organization. XML documents have a well-formed structure, for example,
each XML tag must have an ending tag (such as<bookshelf>...</bookshelf>) and any tag that
begins within another tag must end before the end of the other tag, and must be completely
nested within that other tag. So that </title>,</author>, and </price> all come before </book>,
and in that relative order. An XML document is typically associated with a schema that specifies
its "grammar rules." In other words, the schema specifies what tags are allowed in the document,
the structure of those tags, and other rules about the tags, such as what type of data is expected in
a tag (or no data if it's an empty tag). Because valid XML documents must be well-formed and
conform to the associated schema, it makes it relatively easy to process XML documents. As a
result, XML has been generally adopted as the data language for web services
7. Give differences between valid and well-formed XML document with suitable
example.
Well Formed XML Documents
An XML document with correct syntax is called "Well Formed".
The syntax rules were described in the previous chapters:
A document type definition defines the rules and the legal elements and attributes
for an XML document.
An XML document with correct syntax is called "Well Formed".
An XML document validated against a DTD is both "Well Formed" and "Valid".
The terms "well-formed" and "valid" are important for markup languages, in particular
for XML documents and applications of XML such as XHTML. There is an important difference
between the two terms however, and this should be understood by developers.
Well-Formed Document
Valid Document
The difference between well-formed and valid XML is simple: Valid XML has a DTD associated with it and has
been verified against all the rules contained in the DTD in addition to being well-formed. Merely well-formed
XML, on the other hand, is not necessarily valid, although it may be.
Well-formed XML follows a these rules:
Tags must nest properly. Every beginning and ending tag pair must fully contain any tag pair that
begins inside it. In other words, no start-tag, end-tag, empty-element tag, element, comment, processing
instruction, character reference, or entity reference can begin in one entity and end in another.
In the internal DTD subset, parameter entity references can occur only at the top level, where markup
declarations can occur, and not within markup declarations. Parameter entities are not restricted in the
external DTD subset.
The name in an element's end-tag must match the element type in the start-tag.
No attribute name may appear more than once in the same start-tag or empty-element.
Attribute values cannot contain direct or indirect entity references to external entities.
The replacement text of any entity referred to directly or indirectly in an attribute value (other
than <) must not contain a <.
The declaration of a general entity must precede any reference to it that appears in a default value in
an attribute-list declaration.
Parameter-entity references may only appear in the DTD and have restrictions in the internal DTD
subset.
The only practical way to tell whether you have a valid XML document is to use an automated tool to read in
the document itself, including its DTD, and let the tool parse it. Hand-checking can help but is notoriously error
prone, even when you're careful. It typically takes two, three, or even more attempts to get a new DTD and
document type to load for the first time. Sometimes it takes many more attempts, so be patient and persevere
because you will succeed.
8. List out the elements of WSDL files. What is Abstract Definition and Concrete
Descriptions in WSDL files.
9. Explain SOAP, WSDL and UDDI.
XML 1.0 fairly stable, although Schema are in the process of replacing
DTDs (currently Schema 1.1 being worked on).
SOAP 1.2
WSDL 2.0 (coming out, 1.2 current)
UDDI version 3 (Aug 2003)
What is SOAP?
SOAP, Simple Object Access Protocol is a communication protocol, a way to structure data
before transmitting it, is based on XML standard. It is developed to allow communication
between applications of different platforms and programming languages via internet.
It can use range of protocols such as HTTP, FTP, SMTP, Post office protocol 3(POP3) to
carry documents.
Http-Get, Http-Post works with name/value pair which means transferring complex object is
not possible with these protocols, whereas SOAP serializes complex structure, such as
ASP.NET DataSets, complex arrays, custom types and XML nodes before transmitting and
thus allows exchange of complex objects between applications.
Two components can easily communicate using Remote Procedure Calls protocol. But
because of their compatibility and security issues, most of firewalls and proxy server block
this type of messages. SOAP uses HTTP channel to transport which makes it widely
accepted protocol over the internet.
What is WSDL?
WSDL stands for Web Services Description Language, an XML-based language that
describes Web services and how to access and locate them.
What is UDDI?
UDDI stands for Universal Description, Discovery and Integration. It is an open, Internetbased specification that offers directory service for storing information about web services.
10. Write a program to create web service to convert the temperature from Fahrenheit to Celsius and
Celsius to Fahrenheit.
[System.Web.Services.WebMethod()]
public double FahrenheitToCelsius(double Fahrenheit)
{
return ((Fahrenheit - 32) * 5) / 9;
}
[System.Web.Services.WebMethod()]
public double CelsiusToFahrenheit(double Celsius)
{
return ((Celsius * 9) / 5) + 32;
}