I experience a problem with a Web Service java client written using Axis2
(1.6.2).
The client generates a SOAP message that is valid (and, by using soapUI, has
been verified to result in a valid web service request).
Nevertheless the client throws an exception saying "No user value in rampart
configuration policy".
I have tried "all possible variations (including a) using a client policy.xml
that is loaded - makes no difference at all, b) instantiating a Rampartconfig
and a Policy object - results in doubled usernameToken entries in SOAP
message), and a lot of other ways as well, all without success sofar. I have
even run the client in Eclipse in debug mode using source code of wsse4j-1.6.2
and rampart-1.6.2, and only find that somewhere inside there, the exception is
thrown and the message key "userMissing" is set.
If you know how to overcome this error of an axis2 client, please let me know.
1. The policy section of the wsdl is as follows:
"
<wsp:Policy wsu:Id="CustomerCreation_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SupportingTokens
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" >
<wsp:Policy>
<sp:UsernameToken
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"
/>
</wsp:Policy>
</sp:SupportingTokens>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
"
2. The client axis2.xml has the following entry for UsernameToken
"
<module ref="addressing"/>
<module ref="metadataExchange" />
<module ref="rampart"/>
<parameter name="OutflowSecurity">
<action>
<items>UsernameToken Timestamp</items>
<passwordType>PasswordText</passwordType>
</action>
</parameter>
"
3. The Java client code contains the following entries having bearing on
UsernameToken:
"
configurationContext =
ConfigurationContextFactory.createConfigurationContextFromFileSystem(realPath +
realPathPostFix + "WEB-INF", realPath + realPathPostFix +
"WEB-INF\\conf\\axis2.xml");
customerCreationServiceStub = new
CustomerCreationServiceStub(configurationContext);
serviceClient =
customerCreationServiceStub._getServiceClient();
options = serviceClient.getOptions();
serviceClient.getAxisConfiguration().engageGlobalModules();
serviceClient.engageModule("addressing-1.6.2");
serviceClient.engageModule("rampart-1.6.2");
serviceClient.engageModule("metadataExchange-1.6.2");
// Addressing:
options.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
AddressingConstants.Final.WSA_NAMESPACE);
options.setProperty(AddressingConstants.INCLUDE_OPTIONAL_HEADERS,
Boolean.TRUE); // 2009-05-07, RunoB: Nödvändig för att få med ReplyTo!
options.setAction("http://localhost:9080/marginalenaxis2/services/CustomerCreationService");
options.setMessageId(new UUID().toString()); //2012-04-25, RunoB: new
EndpointReference endpointReferenceReplyTo = new
EndpointReference("http://www.w3.org/2005/08/addressing/anonymous");
options.setReplyTo(endpointReferenceReplyTo);
EndpointReference endpointReferenceTo = new EndpointReference();
endpointReferenceTo = new EndpointReference("http://localhost:" + port +
"/marginalenaxis2/services/CustomerCreationService");
options.setTo(endpointReferenceTo);
// UsernameToken:
options.setProperty(RampartMessageData.KEY_CUSTOM_ISSUED_TOKEN, true);
options.setProperty(WSHandlerConstants.USER, "aaaaa");
options.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
"com.tieto.ws.axis2.callback.UsernameTokenCallbackManager");
serviceClient.setOptions(options);
customerCreationServiceStub._setServiceClient(serviceClient);
"
Best Regards,
Runo Barrdahl
Med vänlig hälsning, / Best Regards,
Runo Barrdahl, civ ing, tekn lic
Tieto Sweden AB, Financial Services
mail: [email protected]
tel (direct): 0709-790 407 / +46-709 790 407
tel (central): 010 481 00 00 / +46-10 481 00 00
fax: 08-86 30 56 / +46-8 86 30 56
web: www.tieto.com