You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ru...@tieto.com on 2012/06/13 08:53:43 UTC

axis2 web service client fails: UsernameToken issue - No user value in rampart configuration policy

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: runo.barrdahl@tieto.com
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


Re: axis2 web service client fails: UsernameToken issue - No user value in rampart configuration policy

Posted by Kishanthan Thangarajah <ks...@gmail.com>.
On Wed, Jun 13, 2012 at 12:23 PM, <Ru...@tieto.com> wrote:

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

One question on engaging modules on the client side. Does the above work?
Normally, we engage modules by calling
serviceClient.engageModule("rampart"). We give only the module name. But I
haven't come across a way by giving the version number also with the name.

And for the issue you reported, there is already one related thread [1]
been discussed. You can find some information from there as-well.

Thanks,
Kishanthan.
[1]
http://markmail.org/search/?q=FW%3A%20No%20user%20value%20in%20rampart%20configuration%20policy#query:FW%3A%20No%20user%20value%20in%20rampart%20configuration%20policy+page:1+mid:xujtpvk24st3lxbz+state:results

> ****
>
> ** **
>
> // 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: runo.barrdahl@tieto.com****
>
> 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****
>
> ** **
>