K2 BLACKPEARL PRODUCT DOCUMENTATION: USER GUIDE
Simple Scalar-Result Web Service Example

Simple Scalar-Result Web Service

This example demonstrates how to call a web service with the following C# signature:

public bool IsOverOrderLimit(double orderTotal)

 

The example service would be located at http://localhost/SampleWebService/CustomerService.asmx.

Introduction

The web service clients generated by the ‘Add Reference’ functionality are instance types. This means that once a reference to the service has been added an instance of the service needs to be created. Once the instance has been created we are able to call instance methods against it.

Part 1: Create the Code Reference Event

Drag a Code Reference Event onto the workflow canvas; or use the Z gesture directly on the canvas. The Code Reference Event Wizard's Welcome page will now open:

Part 2: Add the Reference to the Web Service

Click the ‘Next’ button until the ‘Configure Method Calls’ page is reached. When the page is reached click the ‘Add’ button followed by the ‘Call a constructor’ menu item.


A reference to the web service has not yet been defined – to define it click the ‘Add Reference Button’.

Add a reference to the web service and click Finish. You will be returned to the ‘Manage Process References’ screen; click on Finish to close this screen.

Part 3: Create an Instance of the Web Service Client

The assembly can now be used in the Code Reference Event. Expand the new ‘SampleWebService’ namespace available in the constructor selection tree, followed by the ‘CustomerService’ type and finally select the ‘Create Instance()’ constructor.

Click ‘Next’. The ‘Configure Property Mappings’ page, during construction, allows us to assign or retrieve any static (non-instance) properties and fields on the type before the constructor is called. In this specific scenario there are no static properties or fields; click ‘Next’ to skip the page.

The ‘Configure Call Parameters and Return Value’ page allows us to provide parameters to the method (via either ‘in’ or ‘in/out’ parameters); as well store any values that are returned by the method (via ‘out’, ‘in/out’ parameters or the return value). The return value from the constructor needs to be stored for later use: select the ‘Return Value’ parameter and click the ‘Edit Mapping’ button.

The return type of the constructor is a complex type (that is, any non-scalar type, such as Integer and String); this means that it has to be stored in the local instance storage – and as such you are not allowed to use field parts from the context browser (or literal values in the case of input parameters). The local instance storage is an area to store complex objects for the duration of the reference event. Type a name for the instance and click ‘OK’.

Click the ‘Next’ button once the parameter has been mapped to the local instance storage. The next page allows you to assign or retrieve and static or instance properties after the method (or constructor) call. Click the URL property and click the ‘Edit Mapping’ button. The ‘Output Value’ area allows you to retrieve the value of the property before you store a value in it via the ‘Input Value’ area – you do not need to configure both areas. You may type in the URL, or use any context browser field to configure it:

Click ‘OK’ and continue to the next page. This page allows you to configure and informative name for the call. This name will be shown in the ‘Configure Method Calls’ page as well as provided at runtime in the event that an error occurs.

Click the ‘Next’ button followed by ‘Finish’ to add the constructor call.

Part 4: Perform the Instance Method Call

Click the ‘Add’ button and select the ‘Call an instance method’ menu item; this menu item is only available if instances exist in the wizard. When the ‘Call an Instance Method’ page appears select the instance from the ‘Instance’ drop down, select the method and click ‘Next’:

The ‘Configure Property Mappings’ page, similarly to the same page in the constructor call, allows you to configure fields and properties before calling the method; albeit because an instance currently exists access to instance field and properties is also provided. The URL property was configured in the constructor call and as such does not need to be configured here. Click ‘Next’ to skip the page.

Configure the ‘orderLimit’ parameter and either type in a value or use a field from the context browser:

The ‘Return Value’ is a scalar (non-complex) type; and, as such, can be stored in a data field or XML field.

Once all the mappings have been configured click ‘Next’ to progress to the ‘Configure Property Mappings’ screen. Once again, this page can be skipped. Finally describe the call and finish the wizard.

 

 


K2 blackpearl Help 4.6.10 (4.12060.1690.0)