Вы находитесь на странице: 1из 15

S.P.

B PATEL ENGINEERING COLLEGE SAFFRONY INSTITUTE OF


TECHNOLOGY
SERVICE ORIENTED ARCHITECTURE (PG CSE 2nd SEM)

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.

Message: It is an abstract definition of the data, in the form of a message


presented either as an entire document or as arguments to be mapped to a
method invocation.

Operation: It is the abstract definition of the operation for a message, such as


naming a method, message queue, or business process, that will accept and
process the message.

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.

Port: It is a combination of a binding and a network address, providing the


target address of the service communication.

Service: It is a collection of related end-points encompassing the service


definitions in the file; the services map the binding to the port and include any
extensibility definitions.

In addition to these major elements, the WSDL specification also defines


the following utility elements:

Documentation: This

element

is

used

to

provide

human-readable

documentation and can be included inside any other WSDL element.

Import: This element is used to import other WSDL documents or XML


Schemas.

NOTE: WSDL parts are usually generated automatically using web servicesaware tools.

The WSDL Document Structure


The main structure of a WSDL document looks like this:
<definitions>
<types>
definition of types........
</types>
<message>
definition of a message....
</message>
<portType>
<operation>
definition of a operation.......
</operation>
</portType>
<binding>
definition of a binding....
</binding>
<service>
definition of a service....
</service>
</definitions>

A WSDL document can also contain other elements, like extension

elements and a service element that makes it possible to group together


the definitions of several web services in one single WSDL document.
Proceed further to analyze an example of WSDL Document.
Given below is a WSDL file that is provided to demonstrate a simple

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>

<binding name="Hello_Binding" type="tns:Hello_PortType">


<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice"
use="encoded"/>
</input>

<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 :

sayHelloRequest : firstName parameter

sayHelloresponse: greeting return value

Port Type : sayHello operation that consists of a request and a response


service.

Binding : Direction to use the SOAP HTTP transport protocol.

Service : Service available at http://www.examples.com/SayHello/

Port : Associates the binding with the URI http://www.examples.com/SayHello/


where the running service can be accessed.

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

DTD stands for Document Type

Definition.

DTDs are derived

from SGML syntax.

DTD doesn't support

XSD supports datatypes for elements

datatypes.

and attributes.

DTD doesn't support

XSD supports namespace.

namespace.

DTD doesn't define order for

child elements.

DTD is not extensible.

XSD is extensible.

DTD is not simple to learn.

XSD is simple to learn because you don't

XSD stands for XML Schema Definition.

XSDs are written in XML.

XSD defines order for child elements.

)
7
)

need to learn new language.

DTD provides less control on XML

XSD provides more control on XML

structure.

structure.

LIBRARY DTD

Copied from http://www.vervet.com/

<!DOCTYPE LIBRARY [
<!ELEMENT
<!ELEMENT
<!ELEMENT
<!ELEMENT

LIBRARY (ARTICLE+)>
BOOK (BOOK NAME, AUTHOR NAME, PUBLICATION, ISDN, YEAR, PRICE)>
BOOK NAME (#PCDATA)>
AUTHOR NAME (#PCDATA)>

<!ELEMENT PUBLICATION (#PCDATA)>


<!ELEMENT ISDN (#PCDATA)>
<!ELEMENT YEAR (#PCDATA)>
<!ELEMENT PRICE (#PCDATA)>
<!ATTLIST
<!ATTLIST
<!ATTLIST
<!ATTLIST

BOOK
BOOK
BOOK
BOOK

AUTHOR CDATA #REQUIRED>


EDITOR CDATA #IMPLIED>
DATE CDATA #IMPLIED>
EDITION CDATA #IMPLIED>

<!ENTITY BOOK "Vervet Logic Times">


<!ENTITY PUBLISHER "Vervet Logic Press">
<!ENTITY COPYRIGHT "Copyright 1998 Vervet Logic Press">
]>

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:

XML documents must have a root element

XML elements must have a closing tag

XML tags are case sensitive

XML elements must be properly nested

XML attribute values must be quoted

<?xml version="1.0" encoding="UTF-8"?>


<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

XML Errors Will Stop You


Errors in XML documents will stop your XML applications.
The W3C XML specification states that a program should stop processing an XML
document if it finds an error. The reason is that XML software should be small, fast,
and compatible.
HTML browsers are allowed to display HTML documents with errors (like missing
end tags).
With XML, errors are not allowed.

Syntax-Check Your XML


To help you syntax-check your XML, we have created an XML validator.
Try to syntax-check correct XML:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Try to syntax-check incorrect XML:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to
<from>Jani</from>
<heading>Reminder</pheading>
<body>Don't forget me this weekend!</body>
</note>
Try to syntax-check your own XML :
<?xml version="1.0" encoding="UTF-8"?>

Valid XML Documents


A "well formed" XML document is not the same as a "valid" XML document.
A "valid" XML document must be well formed. In addition, it must conform to a
document type definition.
There are two different document type definitions that can be used with XML:

DTD - The original Document Type Definition

XML Schema - An XML-based alternative to DTD

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".

Valid XML Documents


A "Valid" XML document is a "Well Formed" XML document, which also conforms to
the rules of a DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The DOCTYPE declaration, in the example above, is a reference to an external DTD
file. The content of the file is shown in the paragraph below.
Well-Formed vs 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

A well-formed XML document complies


with the syntactic rules of XML markup.
These rules are strict but basically quite
simple. The XML syntax rules include

A valid XML document means that the


document complies with the rules of a
particular document specification. The
specification is commonly done in an
external DTD file, however it might also
be a DTD section of the XML file, or an
XML based schema file (which also allows
other features).

documents must be self-describing


(they start with an XML
declaration)

a document must contain one or


more elements

documents must contain a single


root element

start and end tags must be used to


identify elements (must have
closing tags)

empty elements must be marked


as such (with a self-closing />)

attribute values must be quoted


(single or double quotes are fine)

element names and attributes


names are case sensitive.

element tags must be correctly


nested (must not overlap)

element names (attribute names)


must start with a letter.

Other interesting things about XML


documents

Before a document can be valid to a


standard, it must start by being wellformed. In fact, its the first requirement
for a valid document: it must be wellformed.
Perhaps the most common examples of
document specifications are for XHTML
documents. There are three separate
document types for XHTML 1.0, Strict,
Transitional and Frameset. See HTML vs
XHTML for more information about
XHTML documents and their doctypes.
The XML specification requires that XML
documents (such as XHTML 1.0 Strict)
include an XML declaration at the
beginning (self-identifying themselves as
XML documents), it is common
practice not to do this for XHTML
documents - most newer web browsers
understand this correctly, but older
browsers such as Internet Explorer
6 do not understand this and as a result
have been known to render the HTML
content incorrectly.

whitespace is preserved (unlike


the way that whitespace is ignored
by web browsers in HTML
documents).

This is also related to the issues of


browsers interpreting HTML+CSS in
"strict" or "quirks" modes.

newlines are only stored as a


single newline character (carriagereturn characters are removed).

HTML style comments <!-- ... -->


(well, SGML actually) work fine as
well.

A well-formed document is a good place


to start, but it does not mean that the
document will make any sense, or that its
content makes any sense. It means that
the formatting rules have been followed,
and this ensures that other uses of the
XML content can take place.
The concept of "well-formed" is a bit like
an English sentence that is punctuated
correctly; start with capital letters, a
single space between works, maybe some
commas, and a period at the end.
However, it says nothing about the
correct spelling of the words, or the
grammatical sense or order of the words.

The Short Summary

Well-formed: XML document meets the syntax requirements of XML.

Valid: XML document is well-formed AND meets the element/attribute/value


requirements of a specific document specification.

Understanding the Difference Between Well-Formed and Valid XML

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 &lt;) must not contain a <.

Characters referred to using character references must be legal characters.

The declaration of a parameter entity must precede any reference to it.

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.

"Well Formed" vs. Valid


When talking about XML documents, two commonly-used terms are "well formed" and "valid." As in "Is your
document marked up in valid and well formed XML?"
Well formed in relation to XML means that it has no syntax, spelling, punctuation, grammar errors, etc. in its markup.
These kinds of errors can cause your XML document to not parse.
Note: An XML Parser is software that reads XML documents and interprets or "parses" the code according to the
XML standard. A parser is needed to perform actions on XML. For example, a parser would be needed to compare an
XML document to a DTD.
In the next section, we will talk about some common errors that prevent an XML document from being well formed.
When you say an XML document is valid, you're saying that the element structure and markup of the XML document
matches a defined standard of relationships, in addition to having well formed markup. In other words, is this XML
document a quality document?
One standard used to validate XML is a DTD, or Document Type Declaration, although XML Schemas are also used.
These standards are useful when dealing with the creation of a number of XML documents for they provide a quality
control measure to ensure that all the documents meet a minimum standard. Another benefit is that it allows for errors
to be detected in the process of creating the XML document, rather than at the end. Later, we'll create a sample DTD
for our email and letter XML documents.
Note: An important thing to remember is that when a document is valid it is also "well formed," but a "well formed"
document is not necessarily valid. Additionally, you can create XML documents without a DTD, but the XML
document can't be considered valid without a document type.

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;
}

Вам также может понравиться