This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to bind authorization code with http request when sending webservice request  RSS feed

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

Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Authorization: Bearer T1QwMTAffgfdyMDEtMWU1ZjlmZDgtMmE3ZC00NTc2LWJmYWQtMzA0NGExNzU1M2Zm
User-Agent: Jakarta Commons-HttpClient/3.1
Content-Length: 799

<soapenv:Envelope xmlns:soapenv="" xmlns:ns="">
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 <SOAP:ENVELOP...> code not in <SOAP:Header>
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 " +
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!