ASP.NET and Web Services, Part 1 - Other SOAP Attributes
(Page 8 of 9 )
A SOAP message defines a SOAP actor, which is divided in two parts:
- A default actor is the intended final recipient of a SOAP message.
- An intermediary actor can act on the content of a SOAP message by modifying the content in some way.
The intermediary actor may manipulate the message content in an unspecified way before forwarding the message to its final destination. Although the message is altered, it is still considered the same message as the one originally sent. An optional header element will transmit data that might not be appropriate to encode in the envelope body. For example, if a default actor receives an encoded, compressed message, it would need to know what type of algorithm is used to compress the code before it could decode the message. Other types of optional headers include the all-important authentication method, routing information, transactions, and security information. A default actor may require the sender to provide authentication information before the recipient can process the message. A message may require specific routing to more than one destination. In addition, the recipient may require security information to determine whether a message is modified before arriving at its destination. For example, it is important for a stock quote to remain in its original state before a brokerage firm can sell the stock to clients. The header element can be added to the SOAP envelope as a child element.Listing 2 demonstrates this.
Listing 2 Defining a child node within the SOAP envelope
<?xml version="1.0" encoding="utf-8" ? >
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<Manifest>BH784Fg23559></Manifest>
</soap:Header>
<soap:Body>
<StockReport>
<StockSymbol>JANS</StockSymbol>
<Price>29.13</Price>
<!--Ouch, a huge financial loss- ->
</StockReport>
</soap:Body>
</soap:Envelope>
The mustUnderstand Attribute
Use the mustUnderstand attribute when information embedded within the header should not be ignored. Therefore, mustUnderstand provides a method for differentiating between noncritical information and mission-critical data that requires attention. By specifying a value of 1 in the header's root element, the identified data cannot be ignored. Listing 3 demonstrates how to use this attribute.
Listing 3 Using the mustUnderstand attribute
<?xml version="1.0" encoding="utf-8"? >
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<TransactionID soap:mustUnderstand="1">19.92</TransactionID>
</soap:Header>
<soap:Body>
<UpdateStockQuote>
<email>DPeltzer@IFCE.com</email>
<f_Name>Dwight</f_Name>
<l_Name>Peltzer</l_Name>
</UpdateStockQuote>
</soap:Body>
</soap:Envelope>
This example shows how the recipient must update the specified stock quote within scope of the client's transaction. In the event the transaction is going awry in some way, the application must roll back any changes made to the client's account. The mechanism used for this is the mustUnderstand attribute, and is achieved by setting the attribute to 1.
Remember: This is part one of chapter 7 .NET & J2EE Interoperability, by Dwight Peltzer (McGraw-Hill/Osborne, ISBN 0-07-223054-1, 2004). If you like what you see, feel free to click on the following link to get your own copy! Buy this book now.
|
Next: More SOAP Attributes >>
More ASP.NET Articles
More By McGraw-Hill/Osborne