Example

Sorting an array of numbers is something every programmer must do at some point in his or her career. C and C++ programmers have traditionally relied on the C runtime library (i.e., qsort ()) for such functionality. The universality of the .NET Runtime means that Visual Basic programmers can also enjoy the luxury of prewritten routines. The VB example below uses the .NET Runtime to sort through a list of ten random numbers. C and C++ examples can be found at < aNET010008. 'VB.NET Example that...

Web Service Example

In this example we will create a simple Calculator web service that exposes one function GetRandomNumber(). Web services require that ASP.NET and IIS are installed on the host machine. Both of these products should be installed automatically by the .NET Framework setup. The first step is to create a directory on your machine that will house your web service (call it C MyWebService). The IIS Configuration tool is then used to turn this directory into a virtual directory, which makes files stored...

Core Concepts

Producing .NET applications and components requires a compiler that translates source code into IL code. VS.NET, Microsoft's new version of Visual Studio, contains three such compilers VB.NET, C , and managed C . While a full examination of these languages is beyond the scope of a CodeNote, each language is briefly discussed below. Code examples throughout this book will demonstrate some of the nuances of each language and the syntactical differences between them. In addition to the IDE, VS.NET...

Custom Attributes

In the previous example, the metadata in WatSoft.DLL allowed us to dynamically call the Add method using reflection. This metadata was of the standard variety it was produced by the C compiler to describe all the types contained within the assembly. Attributes also produce metadata that we can exploit through reflection. Up to this point, we have differentiated between predefined attributes, which already exist, and custom attributes, which you write yourself. The reality is that all attributes...

Summary

A web service is a component that can be accessed over the Internet. To expose a web service, you must have it run within a web server that feeds it incoming HTTP requests and sends method results back to the client as HTTP responses. In the .NET Framework, web services are housed by Internet Information Server IIS and ASP.NET. A web service resides in an .asmx file, which is JIT-compiled when the web service is accessed, or in a precompiled assembly that is automatically loaded when the web...

Http Post Example

Vb6 Http Post

When communicating with a web service via HTTP POST, data is embedded as name-value pairs in the HTTP request's message body. Unlike HTTP GET, the name-value pairs do not appear as part of the URI. In this example we call the Calculator component that we developed in the Web Service Example section of this chapter. Unlike in the Web Service Example, however, we will not use the web browser to communicate via HTTP GET. Instead, we will use a properly formatted HTTP POST request to access the...