Home > Articles > Web Services > XML

Bringing SOAP, Web Services, and .NET together

Discover SOAP's place in the universe by examining the relationships, the benefits, and the future of these three emerging technologies.
This chapter is from the book ๏”€

A Peek at SOAP

Briefly, Simple Object Access Protocol (SOAP) is a way to structure data so that any computer program in any language can read SOAP and send messages in SOAP.

If you're like me, you're impatient when it comes to new technologyโ€”you want to know all the gritty details and the big picture all at once. To sate your appetite, I'll show you two example SOAP packets here, a request for data and a response to that request, but I won't go into any detail yet. That will have to wait until Chapter 2.

The classic SOAP example involves an application needing to know the latest stock price for a certain company. Your application sends a request for information to a remote computer that has the stock price information. That remote computer hears your request via SOAP, and returns the stock price. This type of interaction is known as request-response, and it's how the Web currently works (you ask a server for a Web page, and the server gives it to you).

Here's all the code for the two messages. Example 1โ€“1 shows the request.

Example 1โ€“1 Example SOAP request

<env:Envelope
    xmlns:env="http://www.w3.org/2001/06/soap-envelope">
    <env:Body>
            <m:getStockPrice
            env:encodingStyle="http://www.w3.org/2001/06/
            soap-encoding" xmlns:m="http://www.wire-
            man.com/services/stockquotes">
                <symbol>PSFT</symbol>
            </m:getStockPrice>
    </env:Body>
<env:Envelope>

Example 1โ€“2 shows what the response might look like:

Example 1โ€“2 Example of SOAP response

<env:Envelope xmlns:env="http://www.w3.org/2001/06/soap-envelope">
        <env:Body>
            <m:getStockPriceResponse
            env:encodingStyle="http://www.w3.org/2001/06/
            soap-encoding" xmlns:m="http://www.wire-
            man.com/services/stockquotes">
            <price>45.89</price>
            </m:getStockPriceResponse>
        </env:Body>
</env:Envelope>

These examples will have to hold you until the next chapter, when we dive headfirst into the details of SOAP. The rest of this chapter covers something more important: SOAP's place in the universeโ€”why it exists and why you should care. Here's a preview: Many people think SOAP is the killer app of XML.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.