...
Creating Service Requests
You use the serviceRequest or embeddedserviecRequest tags in your client UI file for your application to access enterprise data using Nexaweb's sql or web services type data services.
The following table provides a brief description of each of these tags:
Tag | Description | When to Use |
serviceRequest | Uses a dataRequestDefintion specified on the server-side to access enterprise data. |
|
embeddedServiceRequest | Specifies an sql statement or web services request in-line within the client UI file to access enterprise data. |
|
serviceRequest
The serviceRequest tag includes the attributes and child elements described in the following table:
Element | Type | Description | Required/Optional |
dataRequestId | Attribute | Specifies an ID to identify the dataRequestDefinition specified in the nexaweb-data.xml file to use to access enterprise data. The serviceResourceDefintion or serviceResourceReference in the dataRequestDefinition specifies or references the specific syntax of the sql statement or web services type request that accesses the data source. | Required |
id | Attribute | Specifies an ID to identify this request. | Required |
onFailure | Attribute | Specifies an MCO or Macro to run when the request fails. | Optional |
onSuccess | Attribute | Specifies an MCO or Macro to run when the request succeeds. | Optional |
target | Attribute | Specifies an object to notify when the request completes. | Optional |
parameters | Child | Specifies parameters for the data source. | Optional |
...
サービスリクエストの作成
アプリケーションのクライアント UI ファイルでserviceRequestまたはembeddedserviecRequestタグを使用して、Nexaweb の SQL または Web サービスタイプのデータサービスを使用したエンタープライズデータにアクセスします。
次の表に、これらの各タグについての簡単な説明を示します。
タグ | 説明 | 使用するタイミング |
serviceRequest | サーバーサイドで指定したdataRequestDefintion を使用してエンタープライズ データにアクセスします。 |
|
embeddedServiceRequest | SQL 文または Web サービスリクエストをクライアント UI ファイルでインライン指定してエンタープライズ データにアクセスします。 |
|
serviceRequest
serviceRequestタグには、次の表に示す属性および子要素が含まれています。
要素 | タイプ | 説明 | 必須/省略可能 |
dataRequestId | 属性 | エンタープライズ データへのアクセスに使用する、nexaweb-data.xmlファイルで指定されたdataRequestDefinitionを識別するための ID を指定します。dataRequestDefinition のserviceResourceDefintionまたはserviceResourceReference で、データソースにアクセスする SQL 文または Web サービスタイプのリクエストの特定のシンタックスが指定または参照されます。 | 必須 |
id | 属性 | このリクエストを識別するための ID を指定します。 | 必須 |
onFailure | 属性 | リクエストが失敗したときに実行する MCO またはマクロを指定します。 | 省略可能 |
onSuccess | 属性 | リクエストが成功したときに実行する MCO またはマクロを指定します。 | 省略可能 |
target | 属性 | リクエストの完了を通知するオブジェクトを指定します。 | 省略可能 |
parameters | 子要素 | データソースのパラメータを指定します。 | 省略可能 |
例:
Code Block |
---|
<serviceRequest dataRequestId="customerStateSearch" |
...
|
...
id="getCustomerByState1">
<parameters>
<parameter name="state">{0}</parameter>
<parameters>
</serviceRequest> |
...
...
embeddedserviceRequest
The embeddedserviceRequest tag includes the attributes and child elements described in the following table:
Element | Type | Description | Required/Optional |
id | Attribute | Specifies an ID to identify this request. | Required |
onFailure | Attribute | Specifies an MCO or Macro to run when the request fails. | Optional |
onSuccess | Attribute | Specifies an MCO or Macro to run when the request succeeds. | Optional |
target | Attribute | Specifies an object to notify when the request completes. | Optional |
sql statement or web service request | N/A | Specifies the syntax of a an sql statement or web services REST or SOAP request. | Required |
...
embeddedserviceRequestタグには、次の表に示す属性および子要素が含まれています。
要素 | タイプ | 説明 | 必須/省略可能 |
id | 属性 | このリクエストを識別するための ID を指定します。 | 必須 |
onFailure | 属性 | リクエストが失敗したときに実行する MCO またはマクロを指定します。 | 省略可能 |
onSuccess | 属性 | リクエストが成功したときに実行する MCO またはマクロを指定します。 | 省略可能 |
target | 属性 | リクエストの完了を通知するオブジェクトを指定します。 | 省略可能 |
SQL 文または Web サービスリクエスト | 該当なし | SQL 文または Web サービスの REST または SOAP リクエストのシンタックスを指定します。 | 必須 |
例:
Code Block |
---|
<embeddedServiceRequest id="getCustomerByState2">
<sqlSelect connectionId="corporate_db" |
...
xmlns="http://nexaweb.com/service/data/sql">
<table>customer_table</table>
<where>state = {0}</where>
</sqlSelect>
</embeddedServiceRequest> |
...
In this example, the embededServiceRequest, getCustomerByState2 uses the connectionID, corporate_db, defined in the nexaweb-sql namespace to execute a select satement that gets data from the customer table where state matches the specified value.
serviceRequest Expanded Example
The following example shows the use of a serviceRequest with the following criteria:
...
この例では、embededServiceRequest、getCustomerByState2によって nexaweb-sql 名前空間で定義されたconnectionID、corporate_dbが使用され、指定された値に状態が一致する顧客テーブルからデータを取得する select 文が実行されます。
serviceRequest の拡張例
次の例では、次の条件で serviceRequestを使用する方法を示します。
- serviceRequestでdataRequestDefinitionを参照する (nexaweb-data.xml file
- ファイル内)
- dataRequestDefinition includes a serviceResourceReference that references a REST request (in
- に REST リクエストを参照するserviceResourceReferenceを含める (nexaweb-webservice.xml file
- ファイル内)
...
Code Block |
---|
...
<data:documentDataSource xmlns:data="http:// |
...
nexaweb. |
...
com/data" id="SearchResultsDS"/> |
...
<dr:serviceRequest id="FlickSrch" target="dataSource://SearchResultsDS" |
...
dataRequestId="FlickrSearchRest" xmlns:dr="http://nexaweb.com/service/data"> |
...
<parameters> |
...
<parameter>{0}</parameter> |
...
</parameters> |
...
</dr:serviceRequest> |
...
クライアント UI には、oncommand イベント (示されていません) の結果として UI にデータを入力するための dataSource であるSearchResultsDSが含まれます。データサービスの serviceRequest であるFlickrSrchを使用して、SearchResultsDSデータソースで外部ソースからデータが取得されます。serviceRequest、FlickrSrch で、渡された引数によってフィルタ処理されたデータがnexaweb.data.xmlファイルの http://nexaweb.com/service/data
...
nexaweb-data.xml
...
Code Block |
---|
...
...
<dataRequestDefinition id="FlickrSearchRest">
<serviceResourceReference dataServiceId="WebService" serviceResourceId="searchFlickrParam" /> |
...
nexaweb-data.xml
...
...
nexaweb-webservice.xml
Code Block |
---|
...
language | html/xml |
---|---|
linenumbers | true |
<webService xmlns="http://nexaweb.com/service/data/webservice"> - <webServiceRequests> - <restRequest id="searchFlickrParam"> |
...
<url>http://www.flickr.com/services/rest</url> - <urlParameters> |
...
<urlParameter name="method">flickr.photos.search</urlParameter> |
...
<urlParameter name="api_key" |
...
>ffdbbd159bdde999cc638c280377a8d1</urlParameter> |
...
<urlParameter name="text">{0}</urlParameter> |
...
<urlParameter name="per_page">25</urlParameter> |
...
</urlParameters> |
...
</restRequest> |
...
nexaweb-webservice.xml ファイルでは、nexaweb-data.xmlファイルのdataRequestDefinition、FlickrSearchRest が restRequest、searchFlickrParamを参照しています。searchFlickrParam によって、URL http://www.flickr.com/services/rest
...
...
...
Putting it All Together
...
まとめ
このクライアント UI ファイルには次のものも含まれます。
Code Block |
---|
...
<button text="Search Flickr" onCommand="serviceRequest://FlickSrch.execute(searchtext.text)"/> |
When this onCommand event fires, the UI executes the FlickSrch serviceRequest. The serviceRequest executes and provides the data to the SearchResultsDS dataSource, through which the UI then displays the data in the UI with the following commands:
...
この onCommand イベントが発生すると、UI によってFlickSrch serviceRequest が実行されます。serviceRequest が実行されると、データがSearchResultsDS dataSource に提供されます。これを使用して、次のコマンドで UI にデータが表示されます。
Code Block |
---|
<data:iterator xmlns:data="http://openxalnexaweb.org/corecom/data" dataSource="SearchResultsDS" dataSource="SearchResultsDS" name="rowIterator" select="//rsp/photos/photo" type="ONE_WAY"> <row> <cell text="{*('@title')}"/> <link alignHorizontal="right" onCommand="{bind( 'select=.;dataSource=rowIterator;formatter=linkFormatter')}" }" text="View Picture"/> </row> </data:iterator> |