Forums Register Login

How to pass a string as http header info

+Pie Number of slices to send: Send
Hi all,
I use REST service along with spring framework.
- I need to pass some info (say a string like username) as header to next class instead of putting the username in url like this :
order/module/{userName}
- The username cannot be in URL due to security issue.
- I tried using HttpServletRequest . But it has only getHeader() and no setHeader().
Can anyone help?
Thanks
+Pie Number of slices to send: Send
 

- I need to pass some info (say a string like username) as header to next class



Are you talking about a whole new request or continuing with the same request?

If the client for this service is a browser, the usual method for passing information to subsequent requests in headers is one or more cookies.

Bill
+Pie Number of slices to send: Send
Thanks for your reply.
-But the client is not a browser. The client is a java class which will change later to some external client.
-I even tried httpentity() but I could not figure it out properly.
-Because in httpentity, the header is attached to response object instead of request. So the header info is not going to THE controller from the
client, instead it is going back to the class that called the client.
Is there anyway I could attach the header to request object??
Thanks.
+Pie Number of slices to send: Send
Hi Rahul,

DId you find a solution for this? I have a smilar requirement but it is for SOAP. My requirement is to have a basic authentication. When I opened a wsdl in SOAP UI this is what I have in header. Please let me know if you find any solution

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:polh="http://ws.pol.com/PolContractService/2012-01-03/Polservice_V1_0" xmlns:sec="http://ws.pol.com/IBC/2010-11-19/securitybasetype_V1" xmlns:mes="http://ws.pol.com/IBC/2010-11-19/messagecontextbasetype_V1" xmlns:man="http://ws.pol.com/PolService/2012-01-03/managecontractrequest_V1" xmlns:con="http://ws.pol.com/Common/2012-01-05/contractbasetype_V1">
<soapenv:Header>
<polh:headerContextParameters>
<securityContextParameters>
<sec:usernameToken>
<sec:userName>?</sec:userName>
<sec:password>?</sec:password>
</sec:usernameToken>
</securityContextParameters>
</polh:headerContextParameters>
</soapenv:Header>

Thanks"
Ajoo
+Pie Number of slices to send: Send
If the client is a Java class under your control then you can put anything you want in the request HTTP headers.

See the documentation for java.net.URLConnection setRequestProperty()

Bill
Everybody! Do the Funky Monkey! Like this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1567 times.
Similar Threads
Referer Header information passed from the Login Jsp page
SOAP authorization problem
like keyword in sql
Getting a Key and Value from a string
is there a way to control header or tail info when printing by java script?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:13:12.