This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes how to bind authorization code with http request when sending webservice request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "how to bind authorization code with http request when sending webservice request" Watch "how to bind authorization code with http request when sending webservice request" New topic
Author

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

Kalaiselvi Senthil
Greenhorn

Joined: Aug 08, 2012
Posts: 3
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to bind authorization code with http request when sending webservice request
 
Similar Threads
Webservices in java
Sharepoint Webservice call from Java Client returns 403-Forbidden
Problem with Axis2 via proxy with NTLM authentication (currently defaulting to BASIC)
Help needed to call a web service after TAM authentication - (401)Unauthorized
Adding authentication in SOAP header..