...
...
Web
...
Nexaweb 4.5
...
Configuring the Web Services Data Service
The web services data service configuration file, nexaweb-webservices.xml, contains the following sections:
Configuration Section | Description |
webServiceDefinitions | Defines the types of web services available through this data service. |
webServiceRequests | Lists REST and SOAP requests defined on the server that your application can use by reference to access external data. Note: You can also specify web service requests in the client UI within an embeddedServiceRequest. |
webServiceDefinitions
The webServiceDefinitions section includes the following element:
Element | Description |
soapServiceDefinition | Defines an ID for the SOAP service, by which serviceRequests can reference this service. |
The soapServiceDefinition element includes the following attributes:
Attribute | Element | Description |
id | soapServiceDefinition | Specifies an ID by which to identify this service in serviceRequests. |
wsdlLocation | soapServiceDefinition | Specifies the location of the wsdl file to use for the SOAP service. |
For example:
Code Block |
---|
<webServiceDefinitions>
<soapServiceDefinition ID = "soap", wsdlLocation="X" >
</soapServiceDefinition>
</webServiceDefinitions> |
To configure web services, in the webServiceDefinitions section of the nexaweb-webservices.xml file:
- Specify an ID for the SOAP service.
- Specify the location of the wsdl file for the SOAP service.
webServiceRequests
This section includes each of the REST and SOAP requests that you want defined on the server and to reference in serviceResourceReference elements of dataDefinitionRequests. You can also create REST and SOAP requests in the client UI file inline in an embeddedServiceRequest.
Creating REST Requests
The web service data service type provides support for communicating with web services implemented using REST architecture.
REST uses HTTP and supports the following methods:
Method | Description |
DELETE | Deletes the resource at the specified resource location. |
GET | Retrieves the resource at the specified resource location. |
POST | Adds the passed data to the specified resource location. |
PUT | Replaces the resource at the specified location with the passed data. |
You specify REST requests using the <restRequest> tag.
The following table describes the <restRequest> tag's attributes and children:
...
この Web サービスのデータ サービスでは、REST (Representational State Transfer) および SOAP (Simple Ojbect Access Protocol) リクエストをサポートしています。
Web サービスのデータサービスの構成
Web サービスのデータサービスのコンフィギュレーションファイル、nexaweb-webservices.xmlには、次のセクションが含まれます。
コンフィギュレーション セクション | 説明 |
webServiceDefinitions | このデータ サービスを通じて利用可能な Web サービスのタイプを定義します。 |
webServiceRequests | サーバー上で定義された REST および SOAP リクエストを示します。このリクエストは、アプリケーションが外部データにアクセスする際に参照によって使用できます。 メモ: Web サービスのリクエストは、クライアント UI の embeddedServiceRequest 内で指定することもできます。 |
webServiceDefinitions
webServiceDefinitionsセクションには次の要素が含まれています。
要素 | 説明 |
soapServiceDefinition | SOAP サービスの ID を定義します。この ID により serviceRequests がこのサービスを参照できます。 |
soapServiceDefinition 要素には、次の属性が含まれています。
属性 | 要素 | 説明 |
id | soapServiceDefinition | serviceRequests でこのサービスを識別するための ID を指定します。 |
wsdlLocation | soapServiceDefinition | SOAP サービスに使用する wsdl ファイルの場所を指定します。 |
例:
<soapServiceDefinition ID = "soap", wsdlLocation="X" > </soapServiceDefinition>
</webServiceDefinitions>
nexaweb-webservices.xmlファイルの webServiceDefinitions セクションで Web サービスを構成するには、次の手順を実行します。
- SOAP サービスの ID を指定します。
- SOAP サービス用の wsdl ファイルの場所を指定します。
このセクションには、サーバー上で定義され、dataDefinitionRequests の serviceResourceReference 要素で参照する、REST および SOAP リクエストがぞれぞれ含まれています。REST および SOAP リクエストは、クライアント UI ファイル内のembeddedServiceRequest にインラインで作成することもできます。
REST リクエストの作成
Web サービスのデータサービス タイプでは、REST アーキテクチャを使用して実装された Web サービスとの通信がサポートされます。
REST では HTTP を使用し、次のメソッドがサポートされています。
メソッド | 説明 |
DELETE | 指定されたリソースの場所でそのリソースを削除します。 |
GET | 指定されたリソースの場所でそのリソースを取得します。 |
POST | 指定されたリソースの場所に、渡されたデータを追加します。 |
PUT | 指定された場所のリソースを、渡されたデータで置き換えます。 |
REST リクエストは、<restRequest> タグを使用して指定します。
次の表に、<restRequest> タグの属性および子属性についての説明を示します。
要素 | タイプ | 説明 | 必須/省略可能 |
id | 属性 | dataDefinitionRequests の serviceResourceReference 要素、またはクライアント UI ファイル内のembeddedServiceRequestで参照されるときに、このリクエストを識別する ID を指定します。 | 必須 |
メソッド | 属性 | 必要に応じて、このリクエストが実行する、上記の HTTP メソッドのいずれかを指定します。 | 省略可能 メソッドを指定しない場合、restRequestではデフォルトで GET メソッドが使用されます。 |
url | 子属性 | REST リソースの場所を指定します。 | 必須 |
urlParameters | 子属性 | REST リソースに送信する追加情報を名前と値のペアのフォーマットで指定する urlParameters をすべて含みます。例: <urlParameter name="username">JR</urlParameter> | Optional 省略可能 |
body | Child | Specifies the content of the body portion of a PUT or POST request. | Optional |
Substitutions
You can substitute any value used in a restRequest by replacing the value with an argument passed to the request, a session variable, or by a pre-processor.
...
子属性 | PUT または POST リクエストの本体部分の内容を指定します。 | 省略可能 |
値の置き換え
restRequestで使用している値は、リクエストに渡される引数、セッション変数、またはプリプロセッサによって置き換えることができます。
例:
Code Block |
---|
<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> </webServiceRequests> |
...
...
...
...
...
The Web Service data service provides support for communicating with web services using SOAP.
SOAP is an XML-based protocol for accessing web services over HTTP.
You specify SOAP requests using the <soapRequest> tag.
A <soapRequest> contains the following:
- The url for locating the web service
- An optional header that can contain session and log information
- A body section that contains the details of the actual request
The following table describes the <soapRequest> tag's attributes and children:
Element | Type | Description | Required/Optional |
id | Attribute | Specifies an ID to identify this request when referenced in a dataRequestDefinition or data request. | Required |
endPointAddress | Child | Specifies the URL location of the Web Service to handle this request. | Required |
soapActionURI | Child | Specifies the URI of the action that the SOAP request uses. | Optional |
header | Child | Specifies the elements that make up the header portion of the SOAP request. Typically added to the request during pre-processing. Attributes: name - A name associated with this element that allows the data service to identify and modify the element during pre-processing. nameSpace - Specifies the name space of the element. | Optional |
body | Child | Specifies the elements that make up the body portion of the SOAP request. Attributes: name - A name associated with this element that allows the data service to identify and modify the element during pre-processing. nameSpace - Specifies the name space of the element. | Required |
For example:
Web サービスのデータ サービスでは、SOAP を使用した Web サービスとの通信がサポートされます。
SOAP は、HTTP を通じて Web サービスにアクセスするための XML ベースのプロトコルです。
SOAP リクエストは、<soapRequest> タグを使用して指定します。
<soapRequest> には、次の要素が含まれています。
- Web サービスを配置するための url
- セッションおよびログ情報を含めることができるオプションのヘッダー
- 実際のリクエストの詳細が含まれる本体セクション
要素 | タイプ | 説明 | 必須/省略可能 |
id | 属性 | dataRequestDefinitionまたはデータリクエストで参照されるときに、このリクエストを識別するための ID を指定します。 | 必須 |
endPointAddress | 子属性 | このリクエストを処理する Web サービスの URL の場所を指定します。 | 必須 |
soapActionURI | 子属性 | SOAP リクエストで使用するアクションの URI を指定します。 | 省略可能 |
header | 子属性 | SOAP リクエストのヘッダー部分を構成する要素を指定します。通常、前処理でリクエストに追加されます。 属性: name - データサービスが前処理でこの要素を識別および変更できるようにするために、要素に関連付ける名前。 nameSpace - 要素の名前空間を指定します。 | 省略可能 |
body | 子属性 | SOAP リクエストの本体部分を構成する要素を指定します。 属性: name - データサービスが前処理でこの要素を識別および変更できるようにするために、要素に関連付ける名前。 nameSpace - 要素の名前空間を指定します。 | 必須 |
例:
Code Block |
---|
<soapRequest id="searchFlickrSoap">
|
...
<endPointAddress>http://api.flickr.com/services/soap/ |
...
</endPointAddress>
<body nameSpace="urn:flickr" localName="FlickrRequest">
<bodyElement name="method">flickr.photos.search</bodyElement>
<bodyElement name="api_key" |
...
>ffbbd159dde99cc678c193777c2d9</bodyElement> <bodyElement name="text">dog</bodyElement> <bodyElement name="per_page">25</bodyElement> </body> </soapRequest> |
...
この例では、SOAP メッセージの searchFlickrSoap が、次の URL で指定されたサーバー上の Web サービスに移動します。http://www.flickr.com/services/soap
...
...
...
...
Using Web Services Requests in a Service Request
You can specify a web services request to use in a serviceRequest in any of the following ways:
...
サービスリクエストでの Web サービスリクエストの使用
使用する Web サービス リクエストを serviceRequest で指定するには、次の方法のいずれかを使用します。
場所 | 説明 | ||
nexaweb-webservices.xml Specify a web service request | in the webServiceRequests section of the server side サーバーサイドのnexaweb-webservice.xml configuration file. Then reference it in a serviceResourceReference of a dataRequestDefinition in the コンフィギュレーションファイルの webServiceRequestsセクションで Web サービス リクエストを指定します。次に、nexaweb-data.xml file. (Finally, reference the dataRequestDefinition in a serviceRequest in the client UI file.ファイル内の dataRequestDefinition の serviceResourceReference でこのリクエストを参照します。(最後に、クライアント UI ファイル内の serviceRequest で dataRequestDefinition を参照します。) | ||
nexaweb-data.xml Specify a web service request in a serviceResourceDefintion of a dataRequestDefinition in the | nexaweb-data.xml file. (Then reference the dataRequestDefinition in a serviceRequest in the client UI file.) | Client UI | Specify a a web service request in an embeddedServiceRequest directly in the client UI file. ファイル内の dataRequestDefinition の serviceResourceDefintion で Web サービスリクエストを指定します。(次に、クライアント UI ファイル内の serviceRequest で dataRequestDefinition を参照します。) |
クライアント UI | クライアント UI ファイル内の embeddedServiceRequest で直接 Web サービスリクエストを指定します。 |