创建 Axis2 Rampart 客户端时出现问题

发布于 2024-11-17 12:05:40 字数 863 浏览 2 评论 0原文

我正在使用 Axis2 创建一个 Web 服务,该服务使用 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 方法需要客户端上具有 Rampart.mar 文件的 Axis2 存储库的路径。它显然需要完整的绝对路径,而不是相对路径。

但是,我正在使用 Java Web Start 部署客户端,并且无法在可能需要运行客户端的每台计算机上放置 Axis2 存储库。它需要通过网络浏览器在任何机器上工作,因此客户端需要的所有内容都在 jar 中。有什么方法可以从客户端应用程序的 jar 加载 Rampart.mar 文件吗?

另一种可能性是使用 ConfigurationContextFactory.createConfigurationContextFromURIs 方法,但这需要我在服务器上创建 axis2+rampart 的在线存储库。有人知道这方面的好指南吗?我仍然更愿意将所有东西都打包在罐子里。

I'm creating a web service using Axis2 which uses Rampart for authentication. In all the samples for Rampart, the client needs to have a client side repository for Axis2. Rampart is started on the client as follows:

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");

The method createConfigurationContextFromFileSystem needs a path to an Axis2 repo on the client which has the rampart.mar file. It apparently needs a full absolute path, not a relative path.

However, I'm deploying my client with Java Web Start and I can't put a Axis2 repo on every machine that may need to run the client. It needs to work from any machine from a web browser so everything the client needs to be in the jar. Is there any way I can load the rampart.mar file from the jar of my client app?

Another possibility would be using the ConfigurationContextFactory.createConfigurationContextFromURIs method, but this would require me to create an online repo of axis2+rampart on the server. Anyone know of a good guide for this? I still would prefer to just package everything in the jar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

找个人就嫁了吧 2024-11-24 12:05:40

如果您不需要 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;
    }
}

If you don't have a need for an Axis2 repository, which I've always found to be the case with Axis2 clients, then you can load a ConfigurationContext without a repository using the following (note the extra detail I add in code comments)...

//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;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文