Hi all,
I am using axis client for accessing webservice. I need to add authentication information in SOAP header.
using wsdl2Java i have generated the stub, skelaton stuff....
From the testClient i am trying the following codes.. But i am not able to view the SOAP Header in the SOAP request..
Way 1.)
******
TpsLocator locator = new TpsLocator();
org.apache.axis.client.Stub s=(org.apache.axis.client.Stub) locator.gettpsSoapDocPort();
s.setHeader("http://my.name.space/headers", "mysecurityheader", "This guy is OK");
Way 2.)
*******
s._setProperty( javax.xml.rpc.Call.USERNAME_PROPERTY, "TPS" );
s._setProperty( javax.xml.rpc.Call.PASSWORD_PROPERTY, "TPSPASS" );
way 3.)
*******
s.setUsername("TPS");
s.setPassword("TPSPASS");
Way 4.)
*******
SOAPHeaderElement wsseSecurity = new SOAPHeaderElement(new PrefixedQName("http://schemas.xmlsoap.org/ws/2002/07/secext", "Security","wsse"));
MessageElement usernameToken = new MessageElement("","wsse:UsernameToken");
MessageElement username = new MessageElement("", "wsse:Username");
MessageElement password = new MessageElement("", "wsse
assword");
username.setObjectValue("johnsmith");
usernameToken.addChild(username);
password.setObjectValue("johns_passwd");
password.addAttribute("","Type", "wsse
asswordText");
usernameToken.addChild(password);
wsseSecurity.addChild(usernameToken);
s.setHeader(wsseSecurity);
Is there any other way to add header ?
Requesting your help..
Regards
Harikrishnan