Using a Web service data source

You can use a Web service as the data source for a DataWindow object with any presentation style.

Using the DataWindow wizard

When you select Web Service as the data source and click Next, the DataWindow wizard opens a page that prompts you to select a WSDL file. The file you select should be in a publicly accessible location for all members of the development team. You can enter the URL to a WSDL, ASMX, or XML file, or you can browse a mapped drive for these types of files.

The Choose WSDL File page of the DataWindow wizard also lets you name the assembly file that the wizard will create. The assembly file serves as an interface between the DataWindow and the Web service. If you do not name the assembly file, the wizard will select a name for you based on the name of the WSDL file entry.

The next step to access a Web service data source is to select a service described in the WSDL, and then one of its public methods. You must then select a parameter for the DataWindow to use as the result set for the method.

A DataWindow typically obtains its data from an array of structures. Because a Web service method can pass an array of structures in one of its arguments rather than in a return value, the wizard prompts you to select one of the method’s arguments or its return value as the designated result set for the method. If you want data for a single row and column only, you can select a parameter that has a simple datatype. You can also select a parameter that is an array of simple datatypes rather than an array of structures.

You complete the wizard as you would when using any other type of data source for your DataWindow. After you complete the wizard, the DataWindow displays in the DataWindow painter. However, there is no equivalent to the SQL painter for a DataWindow with a Web service data source. For this type of DataWindow, you cannot select Design>Data Source from the DataWindow painter menu to change selected columns or modify the DataWindow syntax.

NoteRuntime requirements on a deployment computer To run the Web service DataWindow application from a deployment computer, the assembly file that you generate with the wizard must be copied along with the application executable and required runtime DLLs for Web service applications. For information on the required DLLs and the Runtime Packager tool that you can use to deploy them, see “Deploying DataWindow .NET Applications” in the Programmer’s Guide.

For information on rebuilding an assembly generated by the DataWindow wizard, see “Regenerating an assembly”.

Datatype mappings

Table 3-7 lists .NET datatypes and the DataWindow datatypes to which they map when you use a .NET Web service as a data source. Arrays are also supported for these datatypes except for System.Byte.

Table 3-7: Datatype mapping for .NET datatypes

.NET datatype

DataWindow datatype

System.Boolean

long (Handled as a boolean at runtime.)

System.Byte

ulong

System.DateTime

datetime (Minimum and maximum dates for .NET can be outside the range of dates supported by DataWindow .NET. DataWindow .NET does not support dates prior to the year 1000 or after the year 3000.)

System.Decimal

decimal

System.Double

number

System.Int16

long

System.Int32

long

System.Int64

decimal

System.SByte

long

System.Single

real

System.String

string(40)

System.UInt16

ulong

System.UInt32

ulong

System.UInt64

decimal

The DataWindow can also use a Web service data source that has structures for parameters, as long as the structures are composed of the simple datatypes that can be mapped to DataWindow datatypes. An array of structures can be mapped to n rows with x columns where n is the size of the array and x is the number of members in the structure. Nested structures are not supported.

Using parameters by reference

A parameter passed by reference is a bidirectional [IN,OUT] parameter by definition. The Web Service DataWindow wizard lets you select a Web service method [OUT] or [IN,OUT] parameter, instead of the method return value, to pass a result set to a DataWindow object. However, the parameter you select cannot be used for both a return value and a retrieval argument by the same DataWindow object.

Database-related functions and events

In the Web Service DataWindow, some database or transaction-related functions and events are not supported and meaningless because the Web Service DataWindow has no direct relation to the database. The following functions cannot be used with the Web Service DataWindow: GetSqlSelect, SetSqlSelect, and SetTransaction.

The DbError event is also not supported for the Web Service DataWindow. Instead, you can use the WSError error event to handle errors during retrieve, insert, or update operations.

Using the Web Service Connection object

Some Web services support or require a user ID and password, and other session-related properties like firewall settings. The WebServiceConnection object can provide this information for your DataWindow connections.

You use an instance of the WebServiceConnection object to connect to a Web service by calling the SetWSConnection method.

The following C# code instantiates a WebServiceConnection object with user-related and authentication information, then sets the object as the connection object for a Web service data source:

private void button_Click(object sender, EventArgs e)
{
   WebServiceConnection w = new WebServiceConnection();
   w.UserName =  "johndoe";
   w.Password = "mypassword";
   w.EndPoint = "myendpoint";
   w.AuthenticationMode = "basic";
   w.UseWindowsIntegratedAuthentication = true;
   dw1.SetWSConnection(w);
}

For more information about updating the database with a Web service DataWindow, see “Using a Web service to update the database”.