【问题标题】:Axis 2 (1.6.1) client webservice Basic AuthAxis2 (1.6.1) 客户端 Web 服务基本身份验证
【发布时间】:2012-01-16 14:08:45
【问题描述】:

我正在尝试在 JBoss 5.1.0 GA 中实现客户端 Web 服务 (AXIS 2 1.6.1)。

我已经生成了存根,并且第一次调用(对 mockService)工作正常。

现在我想调用我的 Web 服务(没有 mockService),我需要实现 Basic-Authentication。

我已经实现了基本的身份验证代码,我几乎可以肯定代码中没有错误。

HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername("userName");
basicAuth.setPassword("password");
basicAuth.setPreemptiveAuthentication(true);

stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth);

由于我可以使用 SOAP UI 进行调用,我坚信我的问题是我没有设置我的 “WWS-Password Type”和“WWS TimeToLive”(当我在 SOAP-UI 上禁用这些属性时,我收到相同的错误消息)。

我认为我可能需要在服务器中放置一个axis2.xml 来放置这些属性,但是...... 我什么时候放置我的配置文件(在 JBoss 中)?或者我在哪里定义这个文件的路径? 还是有别的?

谢谢大家。

注意:我尝试了这个解决方案,但没有成功: Adding User/Password to SOAPHeader for WebService client call with AXIS2

我的错误是:

Exception in thread "main" org.apache.axis2.AxisFault: Internal Error (from server)
    at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
    at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
    at  org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
    at myPackage.process(MyStub.java:187)

P.S- 请注意,服务器 Web 服务通过 https 进行通信。

P.S.2 - Tks Edward

【问题讨论】:

  • 我使用这篇文章中的解决方案解决了我的问题:stackoverflow.com/questions/7910776/… 我在 UsernameToken 中有错误的前缀。更正此问题后,它可以正常工作,但此解决方案更像是一种解决方法。 :( 第一个解决方案中的问题是 Axis2 没有在请求中包含任何标头。这是 Axis 错误吗?

标签: java axis2 basic-authentication


【解决方案1】:

仅作记录,我已经使用 Adding User/Password to SOAPHeader for WebService client call with AXIS2 中的解决方案解决了问题。

我有一个拼写错误的标签(在本例中是用户标签)。

非常感谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 2011-10-27
    • 1970-01-01
    • 2010-12-04
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    相关资源
    最近更新 更多