Real World XML Web Services

Copyright © Pearson Education, Inc.2003
All chapters on this site are drafts. These chapters will change before the book is published.

Chapter P: Preface

There’s no doubt that the Web was a catalyst for a revolution that changed the lives of software developers and end users alike. Web services provide the foundation for another profound revolution in the way we build and use applications. It is up to developers like you and I to take this foundation and make the revolution happen. With this book, I aim to give you the information and insight you need to design and build next generation distributed interoperable applications with Web services.

Chapter 1: Introduction to Web Services

You’ve probably heard about Web services and may have read about them. It seems like every trade publication, book, and Web site has some mention of Web services. Unfortunately, most of the current coverage of Web services does not clearly explain what they are really all about, they just trumpet how wonderful Web services are, which comes across as hype. In this chapter I focus on two things: Explaining what Web services are really all about and showing you scenarios where you would use Web services and scenarios where you really should not use them.

Chapter 2: XSD: The Web Services Type System

Web services are all about data exchange between heterogenous applications. This data exchange cannot be accomplished without a common, agreed upon type system that provides standard types as well as the ability to define your own types. This chapter is designed to first get you up and running with XSD, the Web services type system, then show you how XSD is used to specify message formats and validate data exchanged between client and service. This is not intended as a rigorous explanation of XSD – that would require an entire book. Rather, this chapter explains those aspects of XSD that are commonly used in Web services.

Chapter 3: SOAP: Invoking Web Services

In chapter 1 you learned how to invoke a Web service using the SOAP Toolkit and .NET. In this chapter you will learn how these and other tools use SOAP messages to invoke Web services. I will explain the goals and architecture of SOAP and the ways it can be used including messaging and RPC. This chapter’s objective is to teach you what SOAP is capable of doing and how, so that you get a better understanding of the tools you’ll be using such as .NET and the SOAP Toolkit. Such understanding will come in handy when you need to invoke a Web service and you find the tools have limitations that prevent from using them. This and the next chapter are tightly integrated and together complete the picture of how Web services work.

Chapter 4: WSDL: Describing Web Services

Just as XML Schemas are used to describe the data types exposed by Web services, there is a need for a language that can be used to describe the complete interfaces exposed by Web services. In this chapter I explain the concepts and terminology behind the most commonly used language for describing Web service interfaces, the Web Services Description Language. I will show you how to write WSDL documents that describe your Web service’s interface and how to read WSDL documents for services that you want to invoke. The goal of this chapter is to teach you to create the SOAP request messages, and parse the SOAP response messages based on reading a WSDL. Tools, such as the SOAP Toolkit, can do this most of the time, but they sometimes fail especially if there are errors in the WSDL file. By knowing how to read and understand WSDL you can solve these problems yourself and go on to invoke the Web service or enable clients to invoke your Web service.

Chapter 5: Using the SOAP Toolkit

Most of the time you’ll use development tools to help you expose and invoke Web services. This chaper focuses on the Microsoft SOAP Toolkit as an example of such a tool. The toolkit is COM-based and can be used with any COM-capable programming language including Visual Basic 6.0, VBScript, and Visual C++. This chapter explains the toolkit’s components and architecture then shows you how to use it to expose and invoke Web services.

Chapter 6: .NET Web Services

Chapter 1 showed you how easy it is to create and invoke a simple Web service using .NET. This was a good start and was intended to get you hooked on creating Web services. Practically however, the Web services you create will need to do much more than just add two numbers. This chapter will build on what you’ve learned in Chapters 1 through 4 and dive deeper into the details of creating and invoking Web services using .NET. You will learn how to build .NET Web services, customize their WSDL, and invoke them using .NET clients. Even if you have not read chapters 2 – 4, you can still learn a lot from this chapter. If that’s the case, you might want to go back and read chapters 2 – 4 after you’ve read this chapter and worked through the code.

Chapter 7: SOAP Header and Fault

In Chapter 3 you learned how SOAP headers can be used to extend SOAP by including information in the SOAP message outside of the message payload. Applications of SOAP headers include custom session keys (when your application is managing its own sessions), security keys, and digital signatures. .NET makes it easy to send and receive SOAP headers by providing a framework of objects that you use to define your headers then specify which Web methods will use those headers. In this chapter you will learn how to implement SOAP headers with .NET to send additional information between client and service. You’ll also learn to communicate error information in a rich, standard way using SOAP Fault elements.

Chapter 8: Interface-Based Web Service Development

Interface-based programming was popularized with component-based development in the 90’s. Using technologies like COM, you could define an interface then have several components that implement it. Clients could then utilize any of those components by programming against the interface. As your Web services evolve and mature, you will find the need to factor out Web service methods into interfaces, implement existing standard interfaces on your Web services, and program clients against an interface rather than a specific Web service. Interfaces can also be useful for versioning Web services by leaving the old interface intact and implementing a new interface on the same service. WSDL bindings make all this possible. In Chapter 4 you learned all about WSDL bindings and how they define a concrete set of operations and provide the information needed to invoke those operations. A Web service then implements one or more binding and exposes them at a particular location defined by the port. If you haven’t read Chapter 4, you can still read this chapter and learn how to do interface-based programming. However, you will get a lot more out of this chapter if you first read Chapter 4.

Chapter 9: Handling Data in .NET Web Services

Now that you know how to build and invoke Web services you’ll want to do something useful with them. The most common application for Web services is moving data in and out of applications on the intranet or Internet. This chapter explains the options you have for dealing with data in .NET Web services including how to use ADO.NET DataSets, arrays, and your own custom classes.
Chapter 10: Building Reusable Web Services Infrastructure
A typical Web service requires substantial infrastructure. If you are building services mainly for application integration, you’ll probably need to implement security and error handling. Commercial Web services require at least an additional usage tracking system. Instead of implementing this infrastructure as part of the service itself, you should consider implementing it as reusable components that can be used with any Web service. This has all the traditional benefits of code reuse including lowering development time and testing on subsequent projects. But it also has an especially important benefit in the rapidly changing world of Web services: When new standards emerge (and they will), you can replace your existing infrastructure component with one that implements the new standard thereby minimizing change to the Web service code itself. In this chapter you will learn how to leverage a powerful .NET feature named SOAP extensions to implement such reusable infrastructure components.

Chapter 11: UDDI: A Web Service

In a world full of Web services, Universal Description Discovery and Integration, UDDI, becomes an extremely valuable component. As a service built into Windows .NET server, UDDI is also likely to become the de-facto standard Web services catalog within the enterprise. Therefore, to complete the Web services story, I will explain what UDDI is and the scenarios where applications can benefit from private as well as public UDDI implementations. I will focus on writing UDDI-enabled applications that communicate with UDDI as a SOAP-based Web service.

Chapter 12: Other SOAP Toolkits (interoperability)

So far this book has focused on showing you how to build and invoke Web services with VB .NET and VB 6. Being platform-independent, Web services are all about interoperability (interop for short). In fact, the true value of Web services is enabling easy integration of heterogeneous applications. Therefore real-world Web services will likely have a variety of clients written in various languages. This chapter has two objectives that will prepare you for real-world Web services: • Familiarize you with other SOAP toolkits that you might encounter whether in client or service implementations • Point out some potential interop problems and suggest workarounds.

Chapter 13: A Web Service Walkthrough

To wrap up the book and summarize much of what was covered, this chapter walks you through the process of building a live Web service. You will learn how to design Web service messages, how to form those messages with .NET attributes, and how to apply the authentication and authorization infrastructure to a new Web service. You’ll get the most benefit out of this chapter by building the Web service and following along as I explain each step.
Chapter A: DataType Mappings
To read this table, first locate the XML Schema type that you want to look up then read across to find the corresponding SQL Server data type and .NET data type. Note that some schema types have no direct mapping in SQL Server. To handle such types, you need to covert them into a SQL Server supported type. For example, anyURI has no direct mapping in SQL Server, instead you store it as a string, i.e. Varchar.

Chapter B: .NET Web Services Tips and Tricks

Scott Guthrie started a tradition of having a chapter or appendix titled “Tips and Tricks” in ASP.NET-related books. Following this tradition, I decided to write a similar appendix in this book. The tips you’ll find here are really recommendations or best practices that, if used, will serve you well in the long term. Of course things are never black and white so don’t take these as the ten commandments of Web services. Just think long and hard if you are not following these recommendations.