通过Java客户端访问由WS-Security保护的.NET WebService

时间:2014-10-21 09:32:15

标签: java .net web-services ws-security rampart

我正在尝试从Java客户端(AXIS 1.6.2和Rampart)访问通过WS-Security保护的.NET Web服务。

客户端部分:

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("client-repo", null);
AdminServiceStub stub = new AdminServiceStub(null,url);

WSDL(.NET WebService)使用“sp:SecureConversationToken sp:IncludeToken”

<sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">

调用wsdl2java生成的AdminServiceStub失败,出现IllegalArgumentException

生成的存根:

(__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicySubject().attachPolicy(getPolicy("<wsp:Policy xmlns:wsp=\"http://schemas.xmlsoap.org/..."));

此生成的代码行失败,显示:

java.lang.IllegalArgumentException:SecurityContextToken不包含任何sp:IncludeToken属性

有谁知道如何处理这个sp:IncludeToken?

1 个答案:

答案 0 :(得分:0)

我使用随AXIS2 1.6.2附带的wsdl2java.bat

wsdl2java.bat -uri http://localhost/AdminService.svc?wsdl  -uw