Sending files to a Web service

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Integrate > Application integration > Web services connector > Mapping features > Sending and receiving information > Sending and receiving files >

Sending files to a Web service

The following example illustrates how to map information through the WS Connector, when you wish to send files from Bizagi to a Web service.

For more information refer to Sending and receiving files.

 

Sending files from Bizagi to a Web service

To illustrate how to configure integration with Web services, when files stored in the process data model in Bizagi are involved, we will use the Internal Help Desk process as an example.

In this process, we create a new service task called Create reported case record in System A, which comes right after the customer submits a new support ticket.

 

This service task is in charge of sending the attached file sent by the customer (which contains additional detail related to the support ticket) to an external system called System A.

 

WSConnector_Send01

 

 

To configure the Web service invocation, we launch the WS Connector from the Step 6: Integrate (Define Integration Interfaces), and configure the service task with the following steps:

 

1. Enter the Web service main information.

When entering the URL, click the Go button and select the Web method. Click Next.

 

WSConnector_Send02

 

2. Define the input parameters.

Map the information coming from Bizagi which is sent to the Web service.

In this scenario in which we want to send a file, make sure you select the data property (data contains the bytes) of the File attribute or Image attribute.

 
We map to the Web service, the file store in our data model's file attribute called CaseFile:

 

WSConnector_Send03

 

note_pin

Should you need to send out the file's name, then you should map the fileName attribute as well into a separate string parameter.

 

3. Define the output parameters.

Map the incoming response information from the Web service to the attributes in your processes data model (so that it is updated back in Bizagi).

 

For this example, our Web service just returns a confirmation for the success of the operation (a Boolean having true or false).

We map it to the RegisteredinSystemA attribute in our data model:

 

WSConnector_Send04

 

4. Define optional error handling.

For this example, we do not need to configure error handling for a potential invocation failure.

Click Finish.

 

WSConnector_Send05

 

At this point we are done, and we may now execute the process!

 

Additional considerations

When mapping files to a Web service, consider the following:

 

1. When mapping files into string type parameters of a Web service, files are sent by Bizagi as a string encoded in base64.

On the other hand, when files are sent to a bytes array parameter (byte []), these will be sent by Bizagi as a bytes array.

 

2. File type attributes in Bizagi can contain more than 1 file. Image file attributes on the other hand, automatically validate that there is a maximum of 1 uploaded file. For file type attributes, note that:

 

Whenever there is more than 1 file uploaded to a file attribute in the data model, and the Web service expects 1 file only, Bizagi will send the very first file (with the same configuration as in the example above).

Keep in mind that if you need to store only 1 file in your file attributes, you may define this as a setting per form so that users are allowed to upload only 1 file.

 

You may choose to send more than 1 file to a Web service.

This is done automatically by Bizagi, but for this scenario keep in mind that the Web service needs to receive in its input parameters a collection of files (represented as an array of bytes array). You will need to ensure that you map the collection item as well:

 

WSConnector_Send09

 

 

 

Execution

In Bizagi Work portal, we may create a new instance for the Internal Help Desk process to view the configured invocation in which we send files from Bizagi to a Web service.

 

WSConnector_Send08

 

Notice how we attach a file for the Case file attribute in our new case.

 

WSConnector_Send06

 

When clicking on Next, the activity that follows the service task (where the Web service is invoked) will show the updated response.

Notice that the file was sent successfully to the Web service since its response notified that it was Registered in System A (returned true):

 

WSConnector_Send07