Hi Mai,
       It seems that you are using parameter based configuration is
the server side. Please check the WSDL against which you generated
code to check whether it contains any security policies. The code
snippet you have given should work, if the WSDL is policy annotated (
So Axis2 code generator must have attached those policies to the
Stub). But as you are using parameter based configuration of Rampart
in server side, I doubt whether the WSDL contain any policy
information.

thanks,
/nandana

P.S. : I think this discussion should happen in the user list, so
replying to the user list.

On Mon, Mar 31, 2008 at 5:56 PM,  <[EMAIL PROTECTED]> wrote:
> Dear Nandana,
>
>  Thank you very much for your reply. I've read through the tutorial you
>  sent me and I'm able to engage Rampart in my Axis2 client. However, when
>  I sent the request I got the error "WSDoAllReceiver: Incoming message
>  does not contain required Security header". It seems to me that the WSS
>  header was not added to the SOAP request. Below is my client side code:
>
>                         ConfigurationContext ctx =
>  ConfigurationContextFactory
>
>  .createConfigurationContextFromFileSystem(
>                                                         "repository",
>  null);
>                         TradeRetrieverServiceStub stub = new
>  TradeRetrieverServiceStub(
>                                         ctx,
>
>  ConfigReader.getInstance().readConfig().getEndPoint());
>                         ServiceClient sc = stub._getServiceClient();
>                         sc.engageModule("rampart");
>                         ServiceClient client = stub._getServiceClient();
>                         Options options = client.getOptions();
>
>  options.setUserName(ConfigReader.getInstance().readConfig()
>                                         .getUsername());
>
>  options.setPassword(ConfigReader.getInstance().readConfig()
>                                         .getPassword());
>                         GetTrades request = new GetTrades();
>                         TradeFilterDTO filter = new TradeFilterDTO();
>                         Calendar cal = Calendar.getInstance();
>                         cal.set(cal.DATE, cal.get(cal.DATE) - 1);
>                         filter.setFromModifyTime(cal);
>                         request.setFilter(filter);
>                         GetTradesResponse resp =
>  stub.getTrades(request);
>
>  System.out.println(resp.get_return().getDepositTrades());
>
>  The server side is also based on Axis2 and it uses Rampart to check the
>  username and password.
>
>  Please let me know if my code is correct, thanks a lot!
>
>  Regards,
>  Mai Sun
>
>
>
>  -----Original Message-----
>  From: Nandana Mihindukulasooriya [mailto:[EMAIL PROTECTED]
>  Sent: 31 March 2008 13:38
>  To: [EMAIL PROTECTED]
>  Subject: Re: How to add WS-Security header in Axis2 client
>
>  Hi Mai Sun,
>
>  >  is there a way to set username and
>  > password programatically when invoking a web service that requires
>  > WS-Security header?
>
>  use
>     ServiceClient sc = stub._getServiceClient();
>     Options options = sc.getOptions();
>     options.setUserName("username");
>     options.setPassword("password");
>
>  take a look at this tutorial [1] for more information.
>
>  thanks,
>  /nandana
>
>  [1] - http://wso2.org/library/3190
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to