Home > Articles > Programming > Windows Programming

.NET Web Services and SOAP

This chapter introduces the SOAP protocol, describes the SOAP object model, and discusses the serialization of data.
This pre-publication chapter is from Applied SOAP: Implementing .NET Web Services, by Kenn Scribner and Mark Stiver (0672321114). Content is based on Beta2 version of Microsoft's .NET technology.

As you've learned in Chapter 1, "Web Service Fundamentals," SOAP is a critical technological component in the .NET Web Service scheme. SOAP in general defines a mechanism for encoding information into an XML wrapper. For Web Services, SOAP gets a bit more specific when it facilitates the mappings between method signatures and the XML document.

The basic idea behind the use of the SOAP protocol is to interpret a remote method's parameter values at runtime and stuff those values into an XML document, at least as SOAP was originally envisioned. The XML data is then transported to the remote server using the HTTP protocol (other transport protocols are also used, albeit currently outside.NET). If you use SOAP in this manner, you are using the SOAP protocol as an implementation of a more general concept, the invocation of some remote method (implemented as a Web Service). The Remote Procedure Call (RPC) protocol has the same objective: to carry local computer information to a remote computer, even information that might not make sense to a remote system without some conversion (for example, addresses of data to their textual equivalents). This allows the remote computer to execute the remote method on your behalf and return a result.

In this chapter, you'll explore SOAP in some detail to see how it acts as a messaging protocol. To SOAP, the concept of an RPC protocol has a specific meaning. .NET, however, actually uses the SOAP protocol in a dual fashion. It uses SOAP to carry the information back and forth as SOAP messages or as true SOAP RPC calls, depending on how you configure your Web method.

After learning why SOAP is quickly becoming so successful in the industry, you'll dive into the protocol itself to see specifically how SOAP carries remote method information to and from a Web Service. You'll also learn how .NET employs the protocol.

Why Is SOAP Needed?

This innocent-looking question is actually a very good one to ask. RPC protocols grew from research in the mid-1980s that had roots all the way back to Tim Berners-Lee and his description of TCP/IP —and even the invention of Ethernet itself, circa 1970 by Bob Metcalfe, later of 3Com fame. The concept of distributed computing dates back farther than that. The creators of the ENIAC envisioned that one day large numbers of computers would be linked to solve very complex problems.

In the case of RPC and SOAP, the distributed computing issue is simply one of consuming resources on a remote computer as if the remote computer and the calling (local) machine were the same machine. The goal is to seamlessly tie the distributed systems together so that when you call a given method, you don't know (and presumably don't care) whether the call is actually handled by a remote system. In real-world situations, you very often do care, if only because the call latency is greatly increased. It simply takes longer for the method to complete its task. For the purposes of discussing SOAP as a protocol, however, let's ignore those issues and imagine that SOAP, as an RPC protocol actually does seamlessly integrate distributed systems. In critical cases when this model breaks down, you'll find the issue noted in the text.

Why Do You Need to Understand SOAP?

This is also a very good question. After all, given the power of .NET, should you be concerned about underlying protocols .NET uses? As an analogy, when you bring up your e-mail client, do you care how your email is sent or how attachments to your email messages are encoded?

You could make an excellent argument that you don't need to understand SOAP to program Web Services today. .NET handles the details for you. You write the code that .NET requires to handle the Web Service, or the invocation of the Web Service, if you're writing client-side code. Then .NET takes care of the serialization aspects as well as the transmission of the information back and forth. As you'll see in Chapter 5, "Web Services and Description and Discovery," you don't require the more complex aspects of the SOAP protocol because you tell the world what your packets look like using the Web Service Description Language (WSDL).

Those complex SOAP encoding practices were required when client and server had to agree on a protocol using static code. WSDL allows for dynamic packet layout and description—at least, from an early binding perspective—rendering the deeper encoding structures less necessary and even obsolete. This is so because the RPC style of encoding is going out of fashion in favor of the wider range of encoding possibilities that WSDL document/literal encoding offers. You are free to encode information as you see fit rather than blindly follow the SOAP specification itself, at least as far as Section 5 is concerned.

NOTE

In this case, the term early binding refers to tying the client code to the Web Service when the code is compiled. With .NET, the WSDL is read to create proxy source code that is compiled into the client. Dynamic proxy generation, to be used for truly late bound Web Services at runtime, is certainly a possibility but is not currently supported by .NET. It is an alternative offered by the SOAP Toolkit, however, if you require this capability.

But if you really examine what you intend to do, the "why do I care" fac[cd]ade breaks down. Returning to our analogy, an email consumer doesn't need to understand the details associated with the Internet email protocols—or email attachment encoding, for that matter. But developers need to understand these protocols to write code that uses them directly. Blindly trusting infrastructure might get you 80% of the features you require. After all, the infrastructure was designed to satisfy the needs of the general populace. That other 20% or so requires the true ingenuity that comes from understanding the lower levels of the technology.

This chapter won't make you an expert on SOAP, but it will give you the understanding that you'll require to write professional grade Web Services and clients. So back to the initial question—why SOAP? Let's explain it in this way ....

The SOAP Advantage

Probably the best-known RPC protocol is DCE-RPC, which is the Distributed Computing Environment's implementation. Many Unix environments use DCE-RPC, as does Microsoft Windows (which modified it slightly to handle object references across machines to support DCOM). DCE-RPC requires the use of a port mapper, which you'll find listening (monitoring network traffic) on TCP/UDP Port 135. Whenever you want to access a remote computer using DCE-RPC, you access the remote system's port mapper and request a socket address. The actual distributed communication then takes place over the assigned port.

The issue here is actually one of security, when your business-critical servers are safely tucked behind a firewall. For DCE-RPC to work, not only do you have to open Port 135 to the world for port-mapping purposes, but you also need to have a range of other socket addresses available for the general public to use for RPC communications. This very often leads to an opening through which some 13-year-old will ruin your crucial data as well as your day. So it isn't surprising to find nearly every business IT guru locks Port 135 and almost every other port. The one universal exception is Port 80, or Port 443 for secure sockets.

Port 80 is the network socket port used by HTTP, at least as it is nominally configured (Port 8080 is often used to manage the Web server, and HTTP is also spoken there). As you probably already know, the Hypertext Transfer Protocol (HTTP), is the lower-level network protocol used to shuttle Hypertext Markup Language (HTML) documents around the Internet. HTTP is the transport protocol for Web pages, and because you can bet that practically every corporate vice president likes to surf the Net, you'll probably find Port 80 open through any firewall you'll likely encounter.

This is SOAP's secret weapon and one of the sources of its power. It's almost unheard of to find someone blocking Port 80 with a corporate firewall, so SOAP (as bound to HTTP) should pass through corporate firewalls untouched.

The other source of SOAP's power is the fact that the information transported by the HTTP protocol is actually XML (which is why Chapter 3, "Web Services and XML," dealt so heavily with XML within the .NET Framework). To be more specific, the content-type of the HTTP packet is text/xml. The remainder of this chapter is dedicated to uncovering the XML format that SOAP uses to serialize method parameter information, starting with the SOAP XML object model.

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.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020