XML-RPC Service

XML-RPCサービス

The XML-RPC service is the easiest way to add distributed computing and B2B capabilities to your Turbine web application. The current implementation is based on the Apache XML-RPC package which can be found here.

XML-RPCサービスは分散コンピューティングとB2Bの能力をTurbineのウェブアプリケーションへ追加する最も簡単な方法です。 現在の実装はここで提供されているApache XML-RPCパッケージがベースとなっています。

You can leverage the XML-RPC service for your particular needs by creating handlers. A handler is simply a class that performs certain actions: for example you may have a FileHandler that is responsible for sending, getting and removing files from a remote server. For your convenience there is the org.apache.fulcrum.xmlrpc.util.FileHandler class that will perform these operations for you. Please refer to the usage section below for more details.

個別の要求のためのハンドラを作成することにより、XML-RPCサービスは利用可能です。 ハンドラは単純なクラスであり、確実なアクションを実行します: 例としては、リモートサーバからのファイルの送信、取得、削除などの責務をもつFileHandlerがあます。 これらのオペレーションを行ってくれる便利なorg.apache.fulcrum.xmlrpc.util.FileHandlerクラスがあります。 詳細については下の使用方法の章を参照してください。

Configuration

設定

# -------------------------------------------------------------------
#
#  S E R V I C E S
#
# -------------------------------------------------------------------

# Classes for Turbine Services should be defined here.
# Format: services.[name].classname=[implementing class]
#
# To specify properties of a service use the following syntax:
# service.[name].[property]=[value]

# Turbineのサービスのためのクラス群はここに定義します。
# フォーマット: services.[name].classname=[implementing class]
#
# サービスのプロパティを設定するには、以下の書式を使用します:
# service.[name].[property]=[value]

services.XmlRpcService.classname=org.apache.fulcrum.xmlrpc.TurbineXmlRpcService
.
.
.
# -------------------------------------------------------------------
#
#  X M L R P C  S E R V I C E
#
# -------------------------------------------------------------------

# This property specifies which class should be used to parse
# xml for XmlRpc functionality.
#
# Default: org.apache.xerces.parsers.SAXParser

# このプロパティはどのクラスがXmlRpcの機能のための
# xmlをパースするかを指定します。
#
# デフォルト: org.apache.xerces.parsers.SAXParser

services.XmlRpcService.parser=org.apache.xerces.parsers.SAXParser


# This property specifies which port the server part of the XmlRpc
# should listen, if it is active.
#
# Default: 12345

# このプロパティはXmlRpcのサーバがアクティブのとき、どのポートを
# リスンするかを指定します。
#
# デフォルト: 12345

services.XmlRpcService.port=12345


# If any classes are specified here, the Service will create an
# instance of them here and start up a listener on the specified
# port.
#
# Note that the handlers demonstrated are not very useful.  You
# will have to invent your own services.  They do however
# illustrate that any class with a default constructor can be
# added here
#
# The handler parameter without further extension determines
# the default handler for the service
#
# Default: no classes are specified by default

# もしなんらかのクラスがここに指定されているとき、
# サービスはそのインスタンスを作成し、指定されたポートでリスナを立ち上げます。
#
# ここで示したハンドラの例は、余り役に立たないことに注意して下さい。
# 実際には独自のサービス用のハンドラを作成する必要があるでしょう。
# しかし、デフォルトのコンストラクタを持つクラスならどんなものでも
# ここに追加できることをこの例は示しています。
#
# handlerパラメータで後ろに何もついていないものは、
# サービスのデフォルトのハンドラの指定を示します。
#
# デフォルト: デフォルトではなんのクラスも指定されていません

#services.XmlRpcService.handler.$default=java.util.Hashtable
#services.XmlRpcService.handler.stringhandler=java.lang.String


# The following properties allow the transfer of data between
# separate Turbine applications running on different servers.
# This allows B2B type behavior such as sending database
# updates in the form of XML or whatever type of data
# that needs to be shared between Turbine applications
# running on separate servers.

# 以下のプロパティは異なるサーバで実行されている
# Turbineのアプリケーション間のデータの転送を可能にします。
# これはデータベース更新処理をXML形式としたものや、
# 別々のサーバ上で動作しているTurbineアプリケーション間で共有が必要とされる
# なんらかの形式のデータを送信したりするような、
# B2B形式の振る舞いを可能とします。

services.XmlRpcService.handler.file = org.apache.fulcrum.xmlrpc.util.FileHandler
services.XmlRpcService.paranoid = false
services.XmlRpcService.acceptClient = 192.168.1.*
services.XmlRpcService.denyClient =

Usage

使用方法

The following example is taken from the class used to test the file transfer features of the XML-RPC service. The org.apache.fulcrum.xmlrpc.util.FileHandlerTest can be found in the CVS repository. Here is how the FileHandler might be used:

以下の例はXML-RPCサービスを用いたファイルの転送をテストしたクラスから取り出したものです。 org.apache.fulcrum.xmlrpc.util.FileHandlerTestはCVSリポジトリの中に見つけることが出来ます。 これはFileHandlerがどのように使われるかを示したものです:


public class XmlRpcExample
{
    /**

     * We will test the following three operations:
     *
     * 1) Send a file to a remove server
     * 2) Get a file from a remote server
     * 3) Remove a file to a remove server

     * 以下の3つのオペレーションをテストします:
     *
     * 1) リモートサーバへファイルを送信する
     * 2) リモートサーバからファイルを取得する
     * 3) リモートサーバのファイルを削除する
     */
    public void testOperations() throws Exception
    {
        /*
         * @param serverURL
         * @param sourceLocationProperty
         * @param sourceFileName
         * @param destinationLocationProperty
         * @param destinationFileName
         */
        FileTransfer.send("http://www.far-away.com:9000/RPC2",
                          "test.location",
                          "test.txt",
                          "test.location",
                          "test.send");
        /*
         * @param serverURL
         * @param sourceLocationProperty
         * @param sourceFileName
         * @param destinationLocationProperty
         * @param destinationFileName
         */
        FileTransfer.get("http://www.far-away.com:9000/RPC2",
                         "test.location",
                         "test.txt",
                         "test.location",
                         "test.get");

        /*
         * @param serverURL
         * @param sourceLocationProperty
         * @param sourceFileName
         */
        FileTransfer.remove("http://www.far-away.com:9000/RPC2",
                            "test.location",
                            "test.txt");
    }
}