QUESTION
Suppose that a Web service maintains a database of books containing information of the type described in (books.xml). Write a hypothetical SOAP request to display all books by Giada De Laurentiis in year 2005 and two responses. In the first response, there are matching books in the database and they are returned as a list. In the second response, a fault message is returned due to a non-existing author. In each case explain the meaning of the XML elements of the SOAP envelopes.
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<bookstore><book category=”cooking”><author>Giada De Laurentiis</author><year>2005</year><price>30.00</price></book><book category=”children”><author>J K. Rowling</author><year>2005</year><price>29.99</price></book><book category=”web”><author>James McGovern</author><author>Per Bothner</author><author>Kurt Cagle</author><author>James Linn</author><author>Vaidyanathan Nagarajan</author><year>2003</year><price>49.99</price></book><book category=”web” cover=”paperback”><author>Erik T. Ray</author><year>2003</year><price>39.95</price></book></bookstore>
SOLUTION
Introduction:
About SOAP:
SOAP is a lightweight protocol used to exchange of messages in a decentralized and distributed environment. It is used for remote procedure calls. It is used in XML as a payload. It is a platform independent manner. It is flexible for work because of XML properties. It is widely used and scalable. It is widely used wiring protocol.
It contains a serialization pattern, but to do this XML schema is optional.
SOAP elements Structure:
SOAP Envelop:
It is mandatory. In this top element of the XML document representing the message.
SOAP Header:
It is optional. It determines how a recipient of a SOAP message should process the message.
It adds features to the SOAP message such as
- Authentication
- Transaction management
- Payment
- Message routes, etc..
SOAP Body:
It is mandatory. It is used for Remote procedure calls (RPC) and to report error. It is used to extend for the recipient of the message.
Encoding SOAP is similar to how HTTP works.
Maintaining a database of books in the XML file named as books.xml. Making a hypothetical SOAP (Simple Object Access Protocol) request to display all books is from author Giada De Laurentiis in year 2005.
Two types of responses we need to make
- Result must return list of matching books in the database.
- Error message must return if we request for non-existing author.
SOAP fault:
It is used to carry error and status information within a SOAP message. It appears within the body of the SOAP.
- faultcode ( mandatory )
- i. algorithmic mechanism for identifying the fault
- ii. defined in the SOAP specification
- Faultsrting (mandatory)
Human readable explanation of the fault
- Faultactor (optional)
i. Information about who caused the fault to happen
ii. URI value identifying the source
- Detail
i. Error information related only to the Body element.
ii. If not present then indicates that the fault is noe related to the Body element.
SOAP Actions:
- If value is empty string (“”), intent of the SOAP message is provided by the HTTP Request-URI.
- No values mean that there is no indication of the intent of the message.
- The SOAP action HTTP request header field can be used to indicate intent of the SOAP HTTP request.
- Used by services, such as firewalls, to appropriately filter SOAP request message in HTTP.
Matching in the book list are returning from the data base
SOAP request:
<SOAP-ENV-Envelope
xmls:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
SOAP-ENV:encodingStyle=http://schemas.xmlsoop.org/soap/encoding/>
<SOAP-ENV:Header>
<author type=”xsd:string”/> Giada De Laurentiis</author>
< book category type=” xsd:string”> “cooking”</category>
<year type=” xsd:string”>2005</year>
<price type=”xsd:string”/> 30.00</price>
<author type=”xsd:string”/> J K. Rowling </author>
<book category type=” xsd:string”> “children”</category>
<year type=” xsd:string”>2005</year>
<price type=”xsd:string”/> 29.99</price>
<author type=”xsd:string”/> James McGovern</author>
<author type=”xsd:string”/> Per Bothner </author>
<author type=”xsd:string”/> Kurt Cagle</author>
<author type=”xsd:string”/> James Linn </author>
<author type=”xsd:string”/> Vaidyanathan Nagarajan </author>
<year type=” xsd:string”>2003</year>
<price type=”xsd:string”/> 49.99</price>
<author type=”xsd:string”/> Vaidyanathan Nagarajan </author>
<year type=” xsd:string”>2003</year>
<price type=”xsd:string”/> 49.99</price>
<author type=”xsd:string”/> Erik T. Ray</author>
<book category type=” xsd:string”> “web”</category>
<year type=” xsd:string”>2003</year>
<price type=”xsd:string”/> 39.95</price>
<t:transID xmlns:t=”http://a.com/trans”>345</t:transId>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmls:m=http://a.com/Books>
<n1>author</n1>
<n2>name of the book</n2>
<n2>edition of the book</n2>
<n2>price of the book</n2>
<n2>category of the book</n2>
<n2>type of the book</n2>
</m:Add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelop>
<SOAP-ENV:Envelope xmls:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
</SOAP-ENV:Envelop>
In the above statement,
xmls:SOAP-ENV=http://schemas.xmlsoap.xmlsoap.org/soap/envelop/
represents the scope of the message to the SOAP namespace describing the SOAP envelop.
In the above statement,
SOAP ENV:encoding Style=http://schemas.xmlsoap.org/soap/encoding/> represents the type of encoding that is used within the message. For this different data types can be supported.
<SOAP-ENV: Header>
<t:transId xmls:t=http://a.com/trans>1234</t:transId’>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmls:m=”http://a.com/Books”>
<n1> </n1>
</m:Add>
</SOAP-ENV:Body>
In the above statement
<t:transId xmls:t=”http://a.com/trans”> 1234 </t:transId >checking trasaction ID is qualified or not.
In the above statement <m:Add xmlns:m=“http://a.com/Books”> defines the method
SOAP response:
<SOAP-ENV:Envelope
<SOAP-ENV:Envelope xmls:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/ SOAP-ENV:encoding style=http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Header>
<t:transId xmls:t=”http://a.com/trans”> 345 </transId >
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:Add xmls:m=”http://a.com/Books”>
<result>display matching books </result>
</m:AddResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In the above statement <m:AddResponse xmlns:m=“http://a.com/Books”> represents the response method which has been appended.
Fault message returning for non existing author from the data base:
SOAP fault:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Internal Application Error</faultstring>
<detail xmlns:f=“http://www.a.com/BooksFault”>
<f:errorCode>display books</f:errorCode>
<f:errorMsg>non-existing author </f:errorMsg>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
References:
- SOAP Envelope Element, viewed on 29th march 2012, http://www.w3schools.com/soap/soap_envelope.asp
- Scribner K., Stiver M.C 2000, Understanding SOAP, Indianapolis, Indiana.
JD86
But you can order it from our service and receive complete high-quality custom paper. Our service offers Accounting essay sample that was written by professional writer. If you like one, you have an opportunity to buy a similar paper. Any of the academic papers will be written from scratch, according to all customers’ specifications, expectations and highest standards.”