Remote Query Setup for Web Service
Web Service type remotes use remote web service to get remote data. To use Web Service remotes one has to create a web service, which complies with Perfion defined specifications. Then, in order to setup remote query, it is enough to define remote connection to that web service and to configure parameters in Setup XML.
Refer to Perfion Web Service Interface for more information how to implement a web service, which can be used with Web Service remotes.
Remote Connection
Remote connection will specify all parameters needed in order to connect to web service and there is only one parameter needed – URL address. For example: http://ServiceHostName/Service.asmx.
Setup XML Configuration
Web Service type remotes do not use remote query Select Statement for configuration and instead rely only on Setup XML document. All Web Service type remotes must use it. The usage of Setup XML is the same as for other type remotes.
Web Service Remote Data Examples
Single Type Remote
A simple example using Single type remote. Let’s say remote source has the following data:
ProductNumber | Name | PriceInEUR | Description |
1 | Product 1 | 10.6 | Product 1 description |
2 | Product 2 | 15.8 | Product 2 description |
3 | Product 3 | 1125.4 | Product 3 description |
4 | Product 4 | 45.5 | Product 4 description |
5 | Product 5 | 89.1 | Product 5 description |
6 | Product 6 | 6.4 | Product 6 description |
Web service remote connection is shown in Figure 19 and remote query setup is shown in Figure 20.
When remote query is executed, it will create a new XML document with various parameters, which will be used as an argument to GetData web method in remote web service. Here we will show how this new XML document will be created for different modes.
The configuration XML document, which will be sent to GetData web method in Test (setup) mode.
Remote query parameters |
<?xml version="1.0" encoding="utf-16"?> <RemoteQuery name="TestWebServiceQuery" group="All" type="Single" localizable="False"> <Parameter id="Price">10</Parameter> <Key>2</Key> <Key>4</Key> <Key>6</Key> </RemoteQuery> |
The configuration XML document, which will be sent to GetData web method in Test (headers only) mode. The group attribute will be set to “None” value and only the 1st test key will be sent.
Remote query parameters |
<?xml version="1.0" encoding="utf-16"?> <RemoteQuery name="TestWebServiceQuery" group="None" type="Single" localizable="False"> <Parameter id="Price">10</Parameter> <Key>2</Key> </RemoteQuery> |
The configuration XML document, which will be sent to GetData web method in Default mode. Two field elements will be added to limit the number of requested data. Perfion will use only those two fields when showing data and therefore there is no need to send data, which will not be used. In this case we used remote feature with remote data field set to “Name”. It will send Key field (which is always required for remote feature for synchronization) and “Name” field, which is the data field. There will be some key parameters defined based on where in Default mode Perfion will use the data. Note that in this case Perfion may request for data, which is not available in remote source (Key = 7). This is a case, where Perfion has more data than remote data source and it is a normal condition. Remote web service must return only the data it has, so those key values, which were not found will be ignored. Finally, there is Languages parameter, which was not in Setup XML. Languages parameter will be always added automatically to tell web service in which language context data is being used. In this case the example is from the grid, which use only one language - “English” in this case (language code “EN”).
Remote query parameters |
<?xml version="1.0" encoding="utf-16"?> <RemoteQuery name="TestWebServiceQuery" group="All" type="Single" localizable="False"> <Field name="Key" /> <Field name="Name" /> <Parameter id="Price">0</Parameter> <Languages>EN</Languages> <Key>1</Key> <Key>2</Key> <Key>3</Key> <Key>4</Key> <Key>7</Key> </RemoteQuery> |
It is up to web service to define the rules how data has to be read from remote data source. All parameters, which are sent to web service can be used, but not all parameters are mandatory. For example, “Price” parameter in this case may be ignored by web service. If parameters like “Price” will be used, then they will be like filter values for data retrieved from remote data source, e.g. in our example “PriceInEUR” can be filtered using “Price” parameter using more or equal operator (e.g. PriceInEUR >= Price). This is just an example and it is up to web service to define “business logic” how remote data will be read and filtered.
After sending the request to remote web service GetData web method, it will respond with remote data. Below we will show how the data should look like in different modes. The data corresponds to the configuration parameters shown before.
The data returned from web service for Test (setup) mode:
Key | Name | PriceInEUR | Description |
2 | Product 2 | 15.8 | Product 2 description |
4 | Product 4 | 45.5 | Product 4 description |
6 | Product 6 | 6.4 | Product 6 description |
The data returned from web service for Test (headers only) mode:
Key | Name | PriceInEUR | Description |
<Empty, e.g. no data, only headers> |
The data returned from web service for Default mode:
Key | Name |
1 | Product 1 |
2 | Product 2 |
3 | Product 3 |
4 | Product 4 |
In Default mode results will depend on where remote is used in Perfion (grid, Item Editor, etc.) and which type of remote is used. In this case we have created a new remote feature and selected “Name” column as remote data field. Then we used this remote feature in the grid, where key feature values 1, 2, 3 and 4 were used to request remote data.
NOTE: “Key” column can also be named “KeyValue”. Perfion will use “KEYVALUE” column name internally and if “Key” column is used instead, it will rename it automatically. Two different names for key value column are used for backwards compatibility reasons.
Cluster Type Remote
A more complex example using Cluster type remote.
Let’s say remote source has the following data, which have variants of product data, e.g. “Price” in this case is available in “EUR” and “USD” currency:
ProductNumber | Name | Price | Currency | Description |
1 | Product 1 | 10.60 | EUR | Product 1 description |
1 | Product 1 | 12.37 | USD | Product 1 description |
2 | Product 2 | 15.80 | EUR | Product 2 description |
2 | Product 2 | 18.44 | USD | Product 2 description |
3 | Product 3 | 1125.40 | EUR | Product 3 description |
3 | Product 3 | 1313.67 | USD | Product 3 description |
4 | Product 4 | 45.50 | EUR | Product 4 description |
4 | Product 4 | 53.11 | USD | Product 4 description |
5 | Product 5 | 89.10 | EUR | Product 5 description |
5 | Product 5 | 104.01 | USD | Product 5 description |
6 | Product 6 | 6.40 | EUR | Product 6 description |
6 | Product 6 | 7.47 | USD | Product 6 description |
Web Service remote connection is shown in Figure 19 and remote query setup is shown in Figure 21.
If in Setup XML there is at least one Field parameter specified, Perfion will automatically add Key and/or Variant fields, because they are required. The Variant field will be only added if remote has Cluster type data. Perfion will add Key and/or Variant fields only when they are not present, so if they are already were defined by user, than Perfion will not add extra.
The configuration XML document, which will be sent to GetData web method in Test (setup) mode.
Remote query parameters |
<?xml version="1.0" encoding="utf-16"?> <RemoteQuery name="TestWebServiceQuery" group="All" type="Cluster" localizable="False"> <Field name="Key" /> <Field name="Variant" /> <Field name="Price" /> <Variant>EUR</Variant> <Variant>USD</Variant> |
The data returned from web service for Test (setup) mode is shown in the table below. The “Currency” column was chosen as “Variant” data column.
Key | Price | Variant |
2 | 15.8 | EUR |
2 | 18.44 | USD |
4 | 45.5 | EUR |
4 | 53.11 | USD |
6 | 6.4 | EUR |
6 | 7.47 | USD |
NOTE: that in other modes data will be handled similarly, like it was shown in the Single Type Remote example.
Localizable Remote
An example using localizable remote. Let’s say we need to create localizable remote feature with Single type remote data, which would have data for two languages. Remote source data:
ProductNumber | Name | Language | Description |
1 | Product 1 (DAN) | DAN | Product 1 description (DAN) |
1 | Product 1 (EN) | EN | Product 1 description (EN) |
2 | Product 2 (DAN) | DAN | Product 2 description (DAN) |
2 | Product 2 (EN) | EN | Product 2 description (EN) |
3 | Product 3 (DAN) | DAN | Product 3 description (DAN) |
3 | Product 3 (EN) | EN | Product 3 description (EN) |
4 | Product 4 (DAN) | DAN | Product 4 description (DAN) |
4 | Product 4 (EN) | EN | Product 4 description (EN) |
5 | Product 5 (DAN) | DAN | Product 5 description (DAN) |
5 | Product 5 (EN) | EN | Product 5 description (EN) |
6 | Product 6 (DAN) | DAN | Product 6 description (DAN) |
6 | Product 6 (EN) | EN | Product 6 description (EN) |
Web service remote connection is shown in Figure 19 and remote query setup is shown in Figure 22.
Group parameter was not defined in Setup XML, but Perfion will automatically add it with default value, which is “All”. The configuration XML document, which will be sent to GetData web method in Test (setup) mode.
Remote query parameters |
<?xml version="1.0" encoding="utf-16"?> <RemoteQuery name="TestWebServiceQuery" group="All" type="Single" localizable="True"> <Field name="Key" /> <Field name="Name" /> <Languages>DAN,EN</Languages> <Key>2</Key> <Key>4</Key> <Key>6</Key> </RemoteQuery> |
The data returned from web service for Test (setup) mode is shown in the table below.
Key | Name_DAN | Name_EN |
2 | Product 2 (DAN) | Product 2 (EN) |
4 | Product 4 (DAN) | Product 4 (EN) |
6 | Product 6 (DAN) | Product 6 (EN) |
The “Name” parameter was localized, e.g. there was created one data column for “Name” parameter for each language by adding “_<language code>” suffix to the parameter name. Moreover, data was selected so, that it is correctly formatted as required for localizable data.
NOTE: In other modes data will be handled similarly, like it was shown in the Single Type Remote example.