1

認証にRampartを使用するAxis2を使用してWebサービスを作成しています。Rampartのすべてのサンプルで、クライアントにはAxis2のクライアント側リポジトリが必要です。Rampartは、次のようにクライアントで開始されます。

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("path/to/client/repo", null);

SecureServiceStub stub = new SecureServiceStub(ctx,"https://localhost:8443/axis2/services/SecureService");

ServiceClient sc = stub._getServiceClient();

sc.engageModule("rampart");

メソッドcreateConfigurationContextFromFileSystemには、rampart.marファイルを持つクライアント上のAxis2リポジトリへのパスが必要です。相対パスではなく、完全な絶対パスが必要なようです。

ただし、Java Web Startを使用してクライアントをデプロイしているため、クライアントを実行する必要がある可能性のあるすべてのマシンにAxis2リポジトリを配置することはできません。Webブラウザーの任意のマシンから動作する必要があるため、クライアントがすべてjarに含まれている必要があります。クライアントアプリのjarファイルからrampart.marファイルをロードする方法はありますか?

もう1つの可能性は、ConfigurationContextFactory.createConfigurationContextFromURIsメソッドを使用することですが、これには、サーバー上にaxis2+rampartのオンラインリポジトリを作成する必要があります。誰かがこれのための良いガイドを知っていますか?私はまだすべてを瓶に詰めたいと思っています。

4

1 に答える 1

1

Axis2 リポジトリが必要ない場合 (これは Axis2 クライアントの場合に常にあることがわかっています)、以下を使用してリポジトリなしで ConfigurationContext をロードできます (コード コメントに追加した追加の詳細に注意してください)。 ...

//Globally sharable as long as care is taken to call ServiceClient.cleanupTransport()
//in 'finally' block after port call - avoids expensive object creation upon every use
//Must cleanup transport when reusing ConfigurationContext.  See...
//http://issues.apache.org/jira/browse/AXIS2-4357
//http://markmail.org/message/ymqw22vx7j57hwdy#query:axis2%20ConfigurationContext%20thread%20safe+page:1+mid:jh54awy6lf2tk524+state:results
private static final ConfigurationContext CONFIG_CTX = createConfigurationContext();
....
....

private static ConfigurationContext createConfigurationContext()
{
    try
    {
        //See: http://wso2.org/library/585, or specifically...
        //"Option 1 : Create ConfigurationContext by using both the parameters as NULL"
        //Module mar files should be placed in the same location as the Axis2
        //jar files.  Actually, mar files don't need to be literally listed
        //in the classpath, but merely placed in the same relative location
        //as the Axis2 jar files.
        //"In this particular case we have neither service hot-deployment
        //nor service hot-update since we do not have a repository."
        //Even though we do not have a repository in this case, we have an
        //option to add modules (module mar files) in to the classpath and
        //engage them whenever we want."
        return ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
    }
    catch (final Throwable th)
    {
        //Squash.  Shouldn't occur, but ignorable anyway because ServiceClient
        //accepts a null ConfigurationContext argument without complaint.
        return null;
    }
}
于 2011-07-06T19:22:16.667 に答える