简体   繁体   English

无法使标准SSL客户端与axis2 Web服务一起使用

[英]Unable to get standard SSL client to work with axis2 web service

Alright I have a wsdl with web methods that I create stubs via axis2java with the following command: 好的,我有一个wsdl及其Web方法,我使用以下命令通过axis2java创建存根:

wsdl2java -uri https://path/to/service?wsdl -p com.my.java.package

It generates all the required stubs but I am having a hard time actually using them. 它会生成所有必需的存根,但实际上很难使用它们。 I have two URLs both HTTPS however one of them has message encryption with rampart. 我有两个都是HTTPS的URL,但是其中一个具有使用Ramart进行邮件加密的功能。 I have been able to get the more difficult message encrypted URL to work fine. 我已经能够获得更困难的消息加密URL才能正常工作。

I initialize my encrypted stub like follows: 我初始化我的加密存根,如下所示:

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repository", null);

NetWS_0Stub stub = new NetWS_0Stub(ctx, aEndPoint);
ServiceClient client = stub._getServiceClient();

Options options = new Options();
options.setTo(new EndpointReference(aEndPoint));
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,  this.loadPolicy("repository/policy/HTTPS_Policy.xml"));
client.setOptions(options);
client.engageModule("rampart");

return stub;

For my non-encrypted (HTTPS ONLY) I have tried the above method of stub initializing as well as the following: 对于我的非加密(仅HTTPS),我尝试了上述存根初始化方法以及以下方法:

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repository", null);

NetWS_0Stub stub = new NetWS_0Stub(ctx, aEndPoint);
ServiceClient client = stub._getServiceClient();

Options options = new Options();
options.setTo(new EndpointReference(aEndPoint));
client.setOptions(options);

The plain HTTPS stub does not work. 普通的HTTPS存根不起作用。 At best I get a soap header missing exception. 充其量我会得到一个肥皂头缺少异常。 I can however use these web methods via SOAPui. 但是,我可以通过SOAPui使用这些Web方法。 So I know the URL/WSDL/web methods are working great. 因此,我知道URL / WSDL / web方法的效果很好。 I am more familiar with wsimport and not axis2.... axis2 seems much more difficult to do such a simple thing. 我对wsimport而不是axis2更加熟悉。...axis2似乎很难做这种简单的事情。

How am I supposed to setup the stub for calling a non-message encrypted web service? 我应该如何设置用于调用非消息加密Web服务的存根? Why is axis2 such a pain to work with? 为什么使用axis2这么痛苦? Is it just a problem with me not understanding something. 我不了解某件事只是一个问题。 If SOAPui can immediately generate web requests/responses then I feel the axis2 tool should be able to do the same especially since the web methods were creating and accessed via axis2 in glassfish. 如果SOAPui可以立即生成Web请求/响应,那么我觉得axis2工具应该能够做到这一点,特别是因为Web方法是在glassfish中通过axis2创建和访问的。 I have not setup SOAPui with any keystore/truststore it just works when I give it the wsdl. 我尚未使用任何密钥库/信任库来设置SOAPui,但只要给它wsdl,它就可以工作。

If anyone needs particular code samples let me know I am unsure what information would even help someone help me out. 如果有人需要特定的代码示例,请告诉我,我不确定什么信息甚至可以帮助某人帮助我。

I found a solution and will share for any other unfortunate individuals who are working with axis2. 我找到了一个解决方案,并将与其他与axis2合作的不幸人员分享。

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repository", null);

NetWS_0Stub stub = new NetWS_0Stub(ctx, aEndPoint);
ServiceClient client = stub._getServiceClient();

Options options = new Options();
options.setTo(new EndpointReference(aEndPoint));
//Added chunking property:
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
client.setOptions(options);
//Engaged rampart module:
client.engageModule("rampart");

return stub;

Above is the magic combination that worked for me. 上面是对我有用的魔术组合。 Adding the rampart module back in it gave me a chunking exception and after adding that property regarding chunking it worked. 在其中重新添加了rampart模块,这给了我一个分块的异常,并且在添加了有关分块的属性后,它起作用了。 I am not sure if this particular web service I was connecting to has special settings requiring the above config but it was very frustrating getting the perfect combination. 我不确定我要连接的此特定Web服务是否具有需要上述配置的特殊设置,但是获得完美的组合却非常令人沮丧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM