Creating Web Services with Visual C++.NET
- Overview of Web Services and .NET
- Creating a Simple Web Service
- Using a Web Service Within an Application
See all Sams Teach Yourself on InformIT Programming Tutorials.
There are a few people who have already written Visual C++ .NET off as a language that is too difficult and archaic compared to the other .NET languages. They couldn’t be more wrong. Visual C++ .NET is a revolutionary step forward for one of the most widely used languages in the world, and this book will show you many of the features that make this new version more powerful than its counterparts.
My book "SAMS Teach Yourself Visual C++ .NET in 24 Hours" focuses on the new features of Visual C++ .NET rather than rehashing the features that have been present in previous versions of the compiler. In addition, I realize that many developers have legacy code that is just too valuable to rewrite, so this book details the steps you need to take to move those components into the .NET world. That’s not all. In order to show how valuable Visual C++ .NET is within the .NET Framework, you’ll learn 1 thing that sets this .NET language apart from the rest: the ability to mix native unmanaged code within a managed environment, something none of the other .NET languages can do.
When I wrote this book I was amazed at how many new features were added to Visual C++ .NET and equally amazed at how Microsoft updated some of the previous tried and true technologies such as MFC and ATL. My goal when writing this book was to teach you the "how" while still stressing the "why." Make no mistake, Visual C++ .NET is a powerful language that still has a long lifetime and an important role to play in this new world of software development we find ourselves in.
One of the biggest reasons to use the .NET Framework to create applications in Visual C++ .NET over using MFC is the .NET Framework's support for Internet technologies. Even though MDC does provide support for various Internet-related tasks through the WinInet library and ISAPI classes, the .NET Framework expands on these and makes many more technologies available. The .NET Framework makes writing Web-based technology very easy with the provided classes. Web Services are especially well suited to Visual C++ .NET because you can do everything other .NET languages can do, and you can also wrap legacy code with .NET managed classes and make them Web Services for use in Web development. The only caveat to creating Web Services with Visual C++ .NET is that it tends to be more difficult than other .NET languages because C++ itself is a more difficult language to master.
In this hour, you will learn about the features included in the .NET Framework for writing Web Services with Visual C++ .NET. In this hour you will:
Review the Web Service support in the .NET Framework
Write a simple .NET Web Service
Use the new Web Service as part of an application
Debug and test the Web Service
Overview of Web Services and .NET
Web Services are ASP.NET programmable entities that provide particular functionality and are accessible to any other systems through the use of the Simple Object Access Protocol (SOAP), a technology that uses Internet standard XML and HTTP. Web Services are based on the XML standard and other Internet standards in order to provide an interface that is usable not only by other .NET applications but also applications written in other languages and on other platforms.
A Web Service can either be used internally by a single application or exposed to be used externally over the Internet. By using an XML-based protocol as the fundamental communication method, the technology gap between systems is eliminated. Developers can create applications that use many different Web Services together, similar to using objects together.
One of the main characteristics of a Web Service is its high level of abstraction. The implementation and usage of the Web Service is done through an XML-based protocol. Therefore, the client and server need only deal with that technology and understand the inputs, outputs, and location provided by the Web Service.
Understanding the Web Service Infrastructure
Web Services that reside on a Web server are addressed via URLs. Clients of Web Services can discover what Web Services are available, dynamically discover their interfaces, and then use the Web Services, all without being specifically programmed to work with those Web Services.
Essentially a Web Service has the same generic capabilities that a Web browser has with a Web site. The Web browser isn't developed to use a specific Web site, but when it is pointed to one, it knows how to adapt to the content and display it appropriately. A Web Service is similar in that the client does not have to be programmed to know everything about a Web Service. Instead, the client discovers the Web Service's interface and then uses it appropriately.
Web Services must be loosely coupled, use an open standard for communication, and use a universal data format. Rather than using a binary protocol to send and receive data, Web Services uses text-based XML, which in turn leads to several advantages. First of all, it is much easier to debug by reading XML than it is to parse through chunks of binary data. Secondly, by using standard technologies, namely HTTP and XML, third-party vendors can easily create their own implementations for different platforms. Web Services also use an infrastructure that provides a discovery mechanism, a service description to describe how the services should be used, and a standard format with which to communicate. Figure 11.1 shows a representation of the Web Service infrastructure.
Figure 11.1 Web Service infrastructure and communications.