Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Platform 4.5+が必要

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: 

TagDescriptionWhen to Use
serviceRequestUses a dataRequestDefintion specified on the server-side to access enterprise data.
  • To define a data source on the server
  • To specify arguments
  • To use pre- or post-processors
  • To use parameter maps
embeddedServiceRequestSpecifies an sql statement or web services request in-line within the client UI file to access enterprise data.
  • To define a data source in the client UI file
  • To perform simple replacement with parameters
  • Note: You cannot use pre- and post-processors with an embeddedServiceRequest. To use pre- and post-processors, create a serviceRequest.

serviceRequest

The serviceRequest tag includes the attributes and child elements described in the following table:

ElementTypeDescriptionRequired/Optional
dataRequestIdAttributeSpecifies 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
idAttributeSpecifies an ID to identify this request.Required
onFailureAttributeSpecifies an MCO or Macro to run when the request fails.Optional
onSuccessAttributeSpecifies an MCO or Macro to run when the request succeeds.Optional
targetAttributeSpecifies an object to notify when the request completes.Optional
parametersChildSpecifies parameters for the data source.Optional

...


サービスリクエストの作成

アプリケーションのクライアント UI ファイルでserviceRequestまたはembeddedserviecRequestタグを使用して、Nexaweb の SQL または Web サービスタイプのデータサービスを使用したエンタープライズデータにアクセスします。

次の表に、これらの各タグについての簡単な説明を示します。
 
タグ
説明
使用するタイミング
serviceRequest
サーバーサイドで指定したdataRequestDefintion を使用してエンタープライズ データにアクセスします。
  • サーバーでデータソースを定義するとき
  • 引数を指定するとき
  • プリプロセッサまたはポストプロセッサを使用するとき
  • パラメータマップを使用するとき
embeddedServiceRequest
SQL 文または Web サービスリクエストをクライアント UI ファイルでインライン指定してエンタープライズ データにアクセスします。
  • クライアント UI ファイルでデータソースを定義するとき
  • パラメータの単純な置換を実行するとき
  • メモ: embeddedServiceRequest ではプリプロセッサおよびポストプロセッサを使用できません。プリプロセッサおよびポストプロセッサを使用するには、serviceRequest を作成します。

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>

...

 

 
この例では、serviceRequestgetCustomerByState1によってnexaweb-data.xml

...

ファイルで定義されたdataRequestDefintioncustomerStateSearchが使用され、データソースからデータが取得されます。customerStateSearch には引数マッピングが定義され、データが取得される特定の状態の名前をgetCustomerByState1から渡せるようになっています。

embeddedserviceRequest

The embeddedserviceRequest tag includes the attributes and child elements described in the following table:

ElementTypeDescriptionRequired/Optional
idAttributeSpecifies an ID to identify this request.Required
onFailureAttributeSpecifies an MCO or Macro to run when the request fails.Optional
onSuccessAttributeSpecifies an MCO or Macro to run when the request succeeds.Optional
targetAttributeSpecifies an object to notify when the request completes.Optional
sql statement or web service requestN/ASpecifies 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:

...

 


この例では、embededServiceRequestgetCustomerByState2によって nexaweb-sql 名前空間で定義されたconnectionIDcorporate_dbが使用され、指定された値に状態が一致する顧客テーブルからデータを取得する select 文が実行されます。

serviceRequest の拡張例


次の例では、次の条件で serviceRequestを使用する方法を示します。
  • serviceRequestdataRequestDefinitionを参照する (nexaweb-data.xml
  • file
  • ファイル内)
  • dataRequestDefinition
  • includes a serviceResourceReference that references a REST request (in
  • に REST リクエストを参照するserviceResourceReferenceを含める (nexaweb-webservice.xml
  • file
  • ファイル内)

...

クライアント UI

 

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

...

名前空間で定義された外部データソースFlickrSearchRestから取得されます。

nexaweb-data.xml

...

 

Code Block

...

...

<dataRequestDefinition id="FlickrSearchRest">
<serviceResourceReference dataServiceId="WebService" serviceResourceId="searchFlickrParam" />

...

 


nexaweb-data.xml

...

ファイルには、nexweb-webservice.xml

...

ファイルで定義された WebService タイプのデータサービスリクエストsearchFlickrParamを参照するdataRequestDefinitionFlickrSearchRestが定義されています。

nexaweb-webservice.xml

 

Code Block

...

languagehtml/xml
linenumberstrue
<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

...

に対して GET が呼び出されます。その際、method=flickr.photos.search; api_key=ffdbbd159bdde999cc638c280377a8d1; text=

...

ユーザー指定の値; per_page=25

...

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>