Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

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

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.ddd.com/ws/2010">
<soapenv:Header/>
<soapenv:Body>
<ns:GeocodeRequest>
<ns:GeocodeOptions>
<ns:Profile>FR</ns:Profile>
<ns:MaxCandidates>2</ns:MaxCandidates>
--
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 " +
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.
 
machines help you to do more, but experience less. Experience this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!