This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding authentication in SOAP header..

 
hchandran krishnan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#2 and #3 are setting HTTP headers, not SOAP headers.
As to #1 and #4, I don't know - I've never used SOAP headers.
 
Andy Gherna
Greenhorn
Posts: 1
 
Kalaiselvi Senthil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends, I am new to webservices, I am creating a javaclient for our existing webservice, I sent request with username/password to the server and I got authentication token again I want to send request with my authentication token in the header
GeocodeRequest gcreq = new GeocodeRequest();
GeocoderProxy gp = new GeocoderProxy();
GeocoderSoap11Stub gcStub = (GeocoderSoap11Stub) gp.getGeocoder();
( gcStub)._setProperty(Call.SESSION_MAINTAIN_PROPERTY, new Boolean(true));
( gcStub)._setProperty(HTTPConstants.HEADER_AUTHORIZATION,m_strBase64AccessToken);
gres = gcStub.geocode(gcreq);

if I used the above code ,I got the response as (401)Non-Autorisé error like that,I am using jsp/servlet to create a java client, please help me how can I send authentication token with my request

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic