Skip to main content

How to bind authorization value in http request when sending webservice request

No replies
S.Kalai
Offline
Joined: 2012-08-20
Points: 0

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 webservice request with my authentication token as in the header

POST https://lbs.ddd.com/service/soap11/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Authorization: Bearer

T1QwMTAffgfdyMDEtMWU1ZjlmZDgtMmE3ZC00NTc2LWJmYWQtMzA0NGExNzU1M2Zm
User-Agent: Jakarta Commons-HttpClient/3.1
Host: lbs.ddd.com
Content-Length: 799

xmlns:ns="http://www.ddd.com/ws/2010">




FR
2
--
I have the m_strBase64AccessToken value, this given below code for the

webservice request as I got it from automated class(created by WSDL in eclipse->

by using webservice client)

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

I want to add my authorization token above the

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 , For the same webservice when

creating csharp client, we used as
using (OperationContextScope scope = new OperationContextScope

(m_gcClient.InnerChannel))
{
HttpRequestMessageProperty httpRequestProperty = new

HttpRequestMessageProperty();
httpRequestProperty.Headers

[System.Net.HttpRequestHeader.Authorization] = "Bearer " +
Convert.ToBase64String(Encoding.UTF8.GetBytes

(m_strBase64AccessToken));
OperationContext.Current.OutgoingMessageProperties

[HttpRequestMessageProperty.Name] = httpRequestProperty;
res = m_gcClient.Geocode(gcreq);
}
to bind the authorization as above.If you have any idea to create webservice client in JAVA, please help me. Thanks in advance.