Проблема с созданием клиента Axis2 Rampart

Я создаю веб-сервис с помощью Axis2, который использует Rampart для аутентификации. Во всех примерах для 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 необходим путь к репозиторию Axis2 на клиенте, у которого есть файл rampart.mar. Очевидно, ему нужен полный абсолютный путь, а не относительный.

Однако я развертываю свой клиент с помощью Java Web Start и не могу разместить репозиторий Axis2 на каждой машине, на которой может потребоваться запуск клиента. Он должен работать с любого компьютера через веб-браузер, поэтому все, что нужно клиенту, должно быть в банке. Есть ли способ загрузить файл rampart.mar из банка моего клиентского приложения?

Другая возможность - использовать метод ConfigurationContextFactory.createConfigurationContextFromURIs, но для этого мне потребуется создать онлайн-репо вала axis2 + на сервере. Кто-нибудь знает хорошее руководство для этого? Я все же предпочел бы просто упаковать все в банку.


person Sarevok    schedule 28.06.2011    source источник


Ответы (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;
    }
}
person sisu    schedule 06.07.2011