Initializing the SoapClient

Initialization lets the SOAPClient read the Web Service's WSDL file so that it can create and parse the SOAP wrappers required to access the service. To initialize the SOAPClient, you specify the location of the Web Service by calling the soapClient.mssoapinit method. The method takes four arguments. The first required argument is the URL of the WSDL file for the Web Service you want to use. The other three arguments are optional and you may not know any of them immediately The public Web...

Create a Client Application

In this section, you'll create a Visual Basic 6 client application to consume the Mortgage Payment Calculator Web Service. Start a new Visual Basic 6 application and create a new Standard EXE project. Name the project MortgageCalculatorClient, and rename the default form frmMain. Build the user interface as shown in Figure 22.1. Figure 22.1 VB6 Mortgage-Payment CalculatorClient application interface Figure 22.1 VB6 Mortgage-Payment CalculatorClient application interface Note You must download...

The ServerGetLastError and ClearError Methods

Early scripting languages had many problems. One of the worst was poor error handling. Fortunately, C , with its Try-Catch blocks and structured exceptions, has gone a long way toward solving the problem. But there are still errors that you can't trap in code. For example, page preprocessing errors and compilation errors follow the default Internet Information Services IIS error-handling procedure. These errors don't usually crash ASP.NET they can't there may be many other applications that...

Page Counter Example

Suppose you want to create a counter for your page that lets you know how often it is visited. The question is, where can you store the count information If you store it at Session scope, you need to keep the data in memory for every client instance accessing your application. If you store it at Application scope, the count will start over every time your application starts up. If you're going to create a counter that will persist across application instances, you need to store the data in a...

ASPNET Event Sequence

You need to know exactly when events occur and what events you can trap to take full advantage of the ASP.NET environment. You've already seen that you can begin trapping errors even before code execution begins in your page by writing code and setting a breakpoint in the Application_Begin-Request event. But when you first begin an application, that's not the first event in fact, it's not even the second. The only memorable way to discover how ASP handles events is to step through the code....

Simplifying the Special Offers Example

The special offers example you've just seen is an older way of doing things and it works but it certainly isn't the only way. This section contains some ideas and examples that have much the same result but use some .NET helper functions and different client-side techniques to display the special offers from the preceding section. ASP.NET can help you write complex client scripts. The first change you can make is to use a Page class method called RegisterArrayDeclaration. For example, you can...

The DataReader Object

A DataReader object is a pointer into a table of rows that can return individual column values for the current row. You can't create a DataReader object directly. Instead, use the Command object's Execute-Reader method for example Create a connection object OleDbConnection conn null OleDBCommand cmd null OleDBDataReader dr null conn New OleDBConnection Get Northwind cmd new OleDBCommand SELECT FROM Customers, conn create the DataReader dr The last line creates the DataReader. The...

Other HttpApplication Events

In addition to the four main Application and Session events shown in the preceding section, the HttpApplication object exposes other events that are extremely useful and provide C Web applications with capabilities that were unavailable with previous versions of ASP. Although you can write code for these events in the global.asax file, you don't have to you can place code to handle the events in your Web Form class. For example, the HttpApplication.BeginRequest event fires whenever your...

Listing 54 Web Form cmdOKClick Method with ServerSide Validation ch53aspx

private void cmdOK Click object sender, System.EventArgs e System.Text.StringBuilder sb new System.Text.StringBuilder foreach BaseValidator val in Page.Validators sb.Append val.ErrorMessage lblErrors.Visible true lblErrors.Text sb.ToString I dimensioned the variable val in the foreach loop as a BaseValidator object. As the name implies, all Validator objects inherit from BaseValidator therefore, you can assign any Validator object to a variable with the BaseValidator type. Of course, you could...

The HttpApplication and HttpApplicationState Objects

C Web applications can have global values and objects, just as stand-alone Windows programs can have global variables containing values and objects shared between all classes. The HttpApplicationState object holds these values. Like most Web-based collections, it's implemented as a list of names and values in which the name is an indexed String array. You can't access the HttpApplicationState object directly. Instead, you reach it through an HttpApplication object. The ASP.NET runtime maintains...

The RequestForm Property NameValueCollection

The first thing I noticed about the Request.Form property was that it returns a NameValueCollection object. A NameValueCollection object inherits from NameObjectCollectionBase like the HttpFile-Collection and HttpCookieCollection you've already seen and consists of a set of keys, each of which may have multiple values. When the browser requests a page, it also sends a header specifying the content type. You may remember that the lt form gt tag contains an attribute called method, which may be...