Using a Web service data source

Presentation style requirement

You can use a Web service as the data source for a DataWindow having any of the following DataWindow presentation styles:

Composite

Graph

Label

TreeView

Crosstab

Grid

N-Up

 

Freeform

Group

Tabular

 

Support for a Web service data source is not available for RichText and OLE presentation styles.

Using the DataWindow wizard

After you select a supported DataWindow presentation style from the DataWindow tab of the New dialog box, you select a data source for the DataWindow.

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.

Runtime 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 PowerBuilder 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 Applications and Components in Application Techniques.

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

Datatype mappings

The following table 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.

.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 PowerBuilder. PowerBuilder 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

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

For a Web service that you create from a PowerBuilder nonvisual object, a result set must be passed by reference, but it cannot be passed in a method return value. You must use a method argument to pass the result set and then select that argument in any DataWindow object that uses the method as its data source.

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: GetSQLPreview, GetSQLSelect, SetSQLPreview, SetSQLSelect, SetTrans, and SetTransObject.

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 WSConnection object

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

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

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

int ii_return
wsconnection ws_1
ws_1 = create wsconnection
ws_1.username = "johndoe"
ws_1.password = "mypassword"
ws_1.endpoint = "myendpoint"
ws_1.authenticationmode = "basic"
ws_1.usewindowsintegratedauthentication = true
ii_return = dw_1.setwsobject (ws_1)

For more information about setting properties for a Web service connection, see the section called “WSConnection object” in Objects and Controls and the section called “SetWSObject” in DataWindow Reference.

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