axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <mai....@nordea.com>
Subject RE: How to add WS-Security header in Axis2 client
Date Mon, 31 Mar 2008 12:26:59 GMT
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:nandana.cse@gmail.com] 
Sent: 31 March 2008 13:38
To: axis-dev@ws.apache.org
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: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message