You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Anand R <An...@ibsplc.com> on 2011/02/18 11:27:48 UTC
Query - Setting a custom HTTP request header
Hi,
Is there a way to set a custom HTTP request header from a CXF client?
Thanks and regards,
Anand R
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
Re: Query - Setting a custom HTTP request header
Posted by metatech <me...@gmail.com>.
Sergey Beryozkin-5 wrote
>
> OK, you could've used this code too:
>
>
Hi,
For convenience, here is the full code snippet :
Map<String, List<String>> headers = new HashMap<String,
List<String>>();
List<String> acceptedCharset = new LinkedList<String>();
acceptedCharset.add("UTF-8");
acceptedCharset.add("ISO-8859-1");
headers.put("Accept-Charset, acceptedCharset);
client.getRequestContext().put(org.apache.cxf.message.Message.PROTOCOL_HEADERS,
headers);
client.invoke(...)
Regards,
metatech
--
View this message in context: http://cxf.547215.n5.nabble.com/Query-Setting-a-custom-HTTP-request-header-tp3390851p5709996.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Query - Setting a custom HTTP request header
Posted by Sergey Beryozkin <sb...@gmail.com>.
OK, you could've used this code too:
Client cl = ClientProxy.getClient(customerService);
cl.getRequestContext().put(Message.PROTOCOL_HEADERS, map);
as Dan was suggesting...
Cheers, Sergey
On Fri, Feb 18, 2011 at 12:19 PM, Anand R <An...@ibsplc.com> wrote:
> Thanks Sergey, Daniel. I am able to set the HTTP header now. I had to use
> Message.PROTOCOL_HEADERS key to set the HTTP header. Here is my code:
>
> public class HTTPHeaderOutInterceptor extends
> AbstractPhaseInterceptor<Message> {
>
> public HTTPHeaderOutInterceptor() {
>
> super(Phase.WRITE);
> }
>
> public void handleMessage(Message message) throws Fault {
>
> Map<String, List<String>> requestHeaders = (Map<String,
> List<String>>) message.get(Message.PROTOCOL_HEADERS);
> requestHeaders.put("session-id",Arrays.asList("sess#1"));
> }
> }
> Thanks and regards,
> Anand R
>
>
>
> From: Daniel Kulp <dk...@apache.org>
> To: users@cxf.apache.org
> Cc: Sergey Beryozkin <sb...@gmail.com>
> Date: 18-02-11 05:37 PM
> Subject: Re: Query - Setting a custom HTTP request header
>
>
>
> On Friday 18 February 2011 6:18:29 AM Sergey Beryozkin wrote:
>> If you need to do it for a SOAP client then you can register a simple
>> client out interceptor, may be with the Phase.WRITE, and modify the
>> Message.REQUEST_HEADERS property on the current outbound message, this
>> key will return you a Map<String, List<String>> map of request headers
>>
>
> You can do this without an interceptor as well. Grab the request context
> and
> create the Map like above, set the info in the map, set the map onto the
> request context with that key.
>
> Dan
>
>
>
>> cheers, Sergey
>>
>> On Fri, Feb 18, 2011 at 11:08 AM, Anand R <An...@ibsplc.com>
> wrote:
>> > Thanks Raman. I actually need to set a custom header on my HTTP
> request.
>> > I believe the sample code that you have provided sets the SOAP header.
>> > Thanks and regards,
>> > Anand R
>> >
>> >
>> >
>> > From: "Malisetti, Ramanjaneyulu" <Ra...@ca.com>
>> > To: <us...@cxf.apache.org>
>> > Date: 18-02-11 04:18 PM
>> > Subject: RE: Query - Setting a custom HTTP request header
>> >
>> >
>> >
>> > How the client is created. If it is through Dispatch. You can do the
>> > following way.
>> >
>> > resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
>> > getCustomerHeader());
>> >
>> > public Collection<Header> getCustomerHeader() throws
>> > Exception {
>> > SoapHeader sh_client_id=null;
>> > SoapHeader sh_dev_pass=null;
>> > SoapHeader sh_dev_email=null;
>> >
>> >
>> > try {
>> > Document d = createXMLDocument();
>> > Element dev_email =
>> > d.createElement("developer_email");
>> > dev_email.setTextContent("......");
>> > sh_dev_email = new SoapHeader(new
>> > QName("http://www.google.com/api/adsense/v2",
> "AccountServiceService"),
>> > dev_email);
>> > Element dev_pass =
>> > d.createElement("developer_password");
>> > dev_pass.setTextContent("......");
>> > sh_dev_pass = new SoapHeader(new
>> > QName("http://www.google.com/api/adsense/v2",
> "AccountServiceService"),
>> > dev_pass);
>> > Element client_id =
>> > d.createElement("client_id");
>> > client_id.setTextContent("......");
>> > sh_client_id = new SoapHeader(new
>> > QName("http://www.google.com/api/adsense/v2",
> "AccountServiceService"),
>> > client_id);
>> > }catch(Exception e) {
>> > throw new
>> > Exception(e.getMessage(), new
>> > Throwable(e));
>> > }
>> > List<Header> lshd = new
>> > ArrayList<Header>();
>> > lshd.add(sh_dev_email);
>> > lshd.add(sh_dev_pass);
>> > lshd.add(sh_client_id);
>> >
>> > return lshd;
>> > }
>> >
>> > Regards
>> > Raman
>> > -----Original Message-----
>> > From: Anand R [mailto:Anand.Raman@ibsplc.com]
>> > Sent: Friday, February 18, 2011 3:58 PM
>> > To: users@cxf.apache.org
>> > Subject: Query - Setting a custom HTTP request header
>> >
>> > Hi,
>> >
>> > Is there a way to set a custom HTTP request header from a CXF client?
>> > Thanks and regards,
>> > Anand R
>> >
>> >
>> >
>> >
>> >
>> > DISCLAIMER:
>> >
>> > "The information in this e-mail and any attachment is intended only
> for
>> > the person to whom it is addressed and may contain confidential and/or
>> > privileged material. If you have received this e-mail in error, kindly
>> > contact the sender and destroy all copies of the original
> communication.
>> >
>> > IBS makes no warranty, express or implied, nor guarantees the
> accuracy,
>> > adequacy or completeness of the information contained in this email or
>> > any
>> > attachment and is not liable for any errors, defects, omissions,
> viruses
>> >
>> > or for resultant loss or damage, if any, direct or indirect."
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > DISCLAIMER:
>> >
>> > "The information in this e-mail and any attachment is intended only
> for
>> > the person to whom it is addressed and may contain confidential and/or
>> > privileged material. If you have received this e-mail in error, kindly
>> > contact the sender and destroy all copies of the original
> communication.
>> > IBS makes no warranty, express or implied, nor guarantees the
> accuracy,
>> > adequacy or completeness of the information contained in this email or
>> > any attachment and is not liable for any errors, defects, omissions,
>> > viruses or for resultant loss or damage, if any, direct or indirect."
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
>
>
>
>
>
>
> DISCLAIMER:
>
> "The information in this e-mail and any attachment is intended only for
> the person to whom it is addressed and may contain confidential and/or
> privileged material. If you have received this e-mail in error, kindly
> contact the sender and destroy all copies of the original communication.
> IBS makes no warranty, express or implied, nor guarantees the accuracy,
> adequacy or completeness of the information contained in this email or any
> attachment and is not liable for any errors, defects, omissions, viruses
> or for resultant loss or damage, if any, direct or indirect."
>
>
>
>
>
Re: Query - Setting a custom HTTP request header
Posted by Anand R <An...@ibsplc.com>.
Thanks Sergey, Daniel. I am able to set the HTTP header now. I had to use
Message.PROTOCOL_HEADERS key to set the HTTP header. Here is my code:
public class HTTPHeaderOutInterceptor extends
AbstractPhaseInterceptor<Message> {
public HTTPHeaderOutInterceptor() {
super(Phase.WRITE);
}
public void handleMessage(Message message) throws Fault {
Map<String, List<String>> requestHeaders = (Map<String,
List<String>>) message.get(Message.PROTOCOL_HEADERS);
requestHeaders.put("session-id",Arrays.asList("sess#1"));
}
}
Thanks and regards,
Anand R
From: Daniel Kulp <dk...@apache.org>
To: users@cxf.apache.org
Cc: Sergey Beryozkin <sb...@gmail.com>
Date: 18-02-11 05:37 PM
Subject: Re: Query - Setting a custom HTTP request header
On Friday 18 February 2011 6:18:29 AM Sergey Beryozkin wrote:
> If you need to do it for a SOAP client then you can register a simple
> client out interceptor, may be with the Phase.WRITE, and modify the
> Message.REQUEST_HEADERS property on the current outbound message, this
> key will return you a Map<String, List<String>> map of request headers
>
You can do this without an interceptor as well. Grab the request context
and
create the Map like above, set the info in the map, set the map onto the
request context with that key.
Dan
> cheers, Sergey
>
> On Fri, Feb 18, 2011 at 11:08 AM, Anand R <An...@ibsplc.com>
wrote:
> > Thanks Raman. I actually need to set a custom header on my HTTP
request.
> > I believe the sample code that you have provided sets the SOAP header.
> > Thanks and regards,
> > Anand R
> >
> >
> >
> > From: "Malisetti, Ramanjaneyulu" <Ra...@ca.com>
> > To: <us...@cxf.apache.org>
> > Date: 18-02-11 04:18 PM
> > Subject: RE: Query - Setting a custom HTTP request header
> >
> >
> >
> > How the client is created. If it is through Dispatch. You can do the
> > following way.
> >
> > resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
> > getCustomerHeader());
> >
> > public Collection<Header> getCustomerHeader() throws
> > Exception {
> > SoapHeader sh_client_id=null;
> > SoapHeader sh_dev_pass=null;
> > SoapHeader sh_dev_email=null;
> >
> >
> > try {
> > Document d = createXMLDocument();
> > Element dev_email =
> > d.createElement("developer_email");
> > dev_email.setTextContent("......");
> > sh_dev_email = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2",
"AccountServiceService"),
> > dev_email);
> > Element dev_pass =
> > d.createElement("developer_password");
> > dev_pass.setTextContent("......");
> > sh_dev_pass = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2",
"AccountServiceService"),
> > dev_pass);
> > Element client_id =
> > d.createElement("client_id");
> > client_id.setTextContent("......");
> > sh_client_id = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2",
"AccountServiceService"),
> > client_id);
> > }catch(Exception e) {
> > throw new
> > Exception(e.getMessage(), new
> > Throwable(e));
> > }
> > List<Header> lshd = new
> > ArrayList<Header>();
> > lshd.add(sh_dev_email);
> > lshd.add(sh_dev_pass);
> > lshd.add(sh_client_id);
> >
> > return lshd;
> > }
> >
> > Regards
> > Raman
> > -----Original Message-----
> > From: Anand R [mailto:Anand.Raman@ibsplc.com]
> > Sent: Friday, February 18, 2011 3:58 PM
> > To: users@cxf.apache.org
> > Subject: Query - Setting a custom HTTP request header
> >
> > Hi,
> >
> > Is there a way to set a custom HTTP request header from a CXF client?
> > Thanks and regards,
> > Anand R
> >
> >
> >
> >
> >
> > DISCLAIMER:
> >
> > "The information in this e-mail and any attachment is intended only
for
> > the person to whom it is addressed and may contain confidential and/or
> > privileged material. If you have received this e-mail in error, kindly
> > contact the sender and destroy all copies of the original
communication.
> >
> > IBS makes no warranty, express or implied, nor guarantees the
accuracy,
> > adequacy or completeness of the information contained in this email or
> > any
> > attachment and is not liable for any errors, defects, omissions,
viruses
> >
> > or for resultant loss or damage, if any, direct or indirect."
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > DISCLAIMER:
> >
> > "The information in this e-mail and any attachment is intended only
for
> > the person to whom it is addressed and may contain confidential and/or
> > privileged material. If you have received this e-mail in error, kindly
> > contact the sender and destroy all copies of the original
communication.
> > IBS makes no warranty, express or implied, nor guarantees the
accuracy,
> > adequacy or completeness of the information contained in this email or
> > any attachment and is not liable for any errors, defects, omissions,
> > viruses or for resultant loss or damage, if any, direct or indirect."
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
Re: Query - Setting a custom HTTP request header
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 18 February 2011 6:18:29 AM Sergey Beryozkin wrote:
> If you need to do it for a SOAP client then you can register a simple
> client out interceptor, may be with the Phase.WRITE, and modify the
> Message.REQUEST_HEADERS property on the current outbound message, this
> key will return you a Map<String, List<String>> map of request headers
>
You can do this without an interceptor as well. Grab the request context and
create the Map like above, set the info in the map, set the map onto the
request context with that key.
Dan
> cheers, Sergey
>
> On Fri, Feb 18, 2011 at 11:08 AM, Anand R <An...@ibsplc.com> wrote:
> > Thanks Raman. I actually need to set a custom header on my HTTP request.
> > I believe the sample code that you have provided sets the SOAP header.
> > Thanks and regards,
> > Anand R
> >
> >
> >
> > From: "Malisetti, Ramanjaneyulu" <Ra...@ca.com>
> > To: <us...@cxf.apache.org>
> > Date: 18-02-11 04:18 PM
> > Subject: RE: Query - Setting a custom HTTP request header
> >
> >
> >
> > How the client is created. If it is through Dispatch. You can do the
> > following way.
> >
> > resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
> > getCustomerHeader());
> >
> > public Collection<Header> getCustomerHeader() throws
> > Exception {
> > SoapHeader sh_client_id=null;
> > SoapHeader sh_dev_pass=null;
> > SoapHeader sh_dev_email=null;
> >
> >
> > try {
> > Document d = createXMLDocument();
> > Element dev_email =
> > d.createElement("developer_email");
> > dev_email.setTextContent("......");
> > sh_dev_email = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> > dev_email);
> > Element dev_pass =
> > d.createElement("developer_password");
> > dev_pass.setTextContent("......");
> > sh_dev_pass = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> > dev_pass);
> > Element client_id =
> > d.createElement("client_id");
> > client_id.setTextContent("......");
> > sh_client_id = new SoapHeader(new
> > QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> > client_id);
> > }catch(Exception e) {
> > throw new
> > Exception(e.getMessage(), new
> > Throwable(e));
> > }
> > List<Header> lshd = new
> > ArrayList<Header>();
> > lshd.add(sh_dev_email);
> > lshd.add(sh_dev_pass);
> > lshd.add(sh_client_id);
> >
> > return lshd;
> > }
> >
> > Regards
> > Raman
> > -----Original Message-----
> > From: Anand R [mailto:Anand.Raman@ibsplc.com]
> > Sent: Friday, February 18, 2011 3:58 PM
> > To: users@cxf.apache.org
> > Subject: Query - Setting a custom HTTP request header
> >
> > Hi,
> >
> > Is there a way to set a custom HTTP request header from a CXF client?
> > Thanks and regards,
> > Anand R
> >
> >
> >
> >
> >
> > DISCLAIMER:
> >
> > "The information in this e-mail and any attachment is intended only for
> > the person to whom it is addressed and may contain confidential and/or
> > privileged material. If you have received this e-mail in error, kindly
> > contact the sender and destroy all copies of the original communication.
> >
> > IBS makes no warranty, express or implied, nor guarantees the accuracy,
> > adequacy or completeness of the information contained in this email or
> > any
> > attachment and is not liable for any errors, defects, omissions, viruses
> >
> > or for resultant loss or damage, if any, direct or indirect."
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > DISCLAIMER:
> >
> > "The information in this e-mail and any attachment is intended only for
> > the person to whom it is addressed and may contain confidential and/or
> > privileged material. If you have received this e-mail in error, kindly
> > contact the sender and destroy all copies of the original communication.
> > IBS makes no warranty, express or implied, nor guarantees the accuracy,
> > adequacy or completeness of the information contained in this email or
> > any attachment and is not liable for any errors, defects, omissions,
> > viruses or for resultant loss or damage, if any, direct or indirect."
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Query - Setting a custom HTTP request header
Posted by Sergey Beryozkin <sb...@gmail.com>.
If you need to do it for a SOAP client then you can register a simple
client out interceptor, may be with the Phase.WRITE, and modify the
Message.REQUEST_HEADERS property on the current outbound message, this
key will return you a Map<String, List<String>> map of request headers
cheers, Sergey
On Fri, Feb 18, 2011 at 11:08 AM, Anand R <An...@ibsplc.com> wrote:
> Thanks Raman. I actually need to set a custom header on my HTTP request. I
> believe the sample code that you have provided sets the SOAP header.
> Thanks and regards,
> Anand R
>
>
>
> From: "Malisetti, Ramanjaneyulu" <Ra...@ca.com>
> To: <us...@cxf.apache.org>
> Date: 18-02-11 04:18 PM
> Subject: RE: Query - Setting a custom HTTP request header
>
>
>
> How the client is created. If it is through Dispatch. You can do the
> following way.
>
> resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
> getCustomerHeader());
>
> public Collection<Header> getCustomerHeader() throws
> Exception {
> SoapHeader sh_client_id=null;
> SoapHeader sh_dev_pass=null;
> SoapHeader sh_dev_email=null;
>
>
> try {
> Document d = createXMLDocument();
> Element dev_email =
> d.createElement("developer_email");
> dev_email.setTextContent("......");
> sh_dev_email = new SoapHeader(new
> QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> dev_email);
> Element dev_pass =
> d.createElement("developer_password");
> dev_pass.setTextContent("......");
> sh_dev_pass = new SoapHeader(new
> QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> dev_pass);
> Element client_id =
> d.createElement("client_id");
> client_id.setTextContent("......");
> sh_client_id = new SoapHeader(new
> QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
> client_id);
> }catch(Exception e) {
> throw new
> Exception(e.getMessage(), new
> Throwable(e));
> }
> List<Header> lshd = new
> ArrayList<Header>();
> lshd.add(sh_dev_email);
> lshd.add(sh_dev_pass);
> lshd.add(sh_client_id);
>
> return lshd;
> }
>
> Regards
> Raman
> -----Original Message-----
> From: Anand R [mailto:Anand.Raman@ibsplc.com]
> Sent: Friday, February 18, 2011 3:58 PM
> To: users@cxf.apache.org
> Subject: Query - Setting a custom HTTP request header
>
> Hi,
>
> Is there a way to set a custom HTTP request header from a CXF client?
> Thanks and regards,
> Anand R
>
>
>
>
>
> DISCLAIMER:
>
> "The information in this e-mail and any attachment is intended only for
> the person to whom it is addressed and may contain confidential and/or
> privileged material. If you have received this e-mail in error, kindly
> contact the sender and destroy all copies of the original communication.
>
> IBS makes no warranty, express or implied, nor guarantees the accuracy,
> adequacy or completeness of the information contained in this email or
> any
> attachment and is not liable for any errors, defects, omissions, viruses
>
> or for resultant loss or damage, if any, direct or indirect."
>
>
>
>
>
>
>
>
>
>
>
> DISCLAIMER:
>
> "The information in this e-mail and any attachment is intended only for
> the person to whom it is addressed and may contain confidential and/or
> privileged material. If you have received this e-mail in error, kindly
> contact the sender and destroy all copies of the original communication.
> IBS makes no warranty, express or implied, nor guarantees the accuracy,
> adequacy or completeness of the information contained in this email or any
> attachment and is not liable for any errors, defects, omissions, viruses
> or for resultant loss or damage, if any, direct or indirect."
>
>
>
>
>
RE: Query - Setting a custom HTTP request header
Posted by Anand R <An...@ibsplc.com>.
Thanks Raman. I actually need to set a custom header on my HTTP request. I
believe the sample code that you have provided sets the SOAP header.
Thanks and regards,
Anand R
From: "Malisetti, Ramanjaneyulu" <Ra...@ca.com>
To: <us...@cxf.apache.org>
Date: 18-02-11 04:18 PM
Subject: RE: Query - Setting a custom HTTP request header
How the client is created. If it is through Dispatch. You can do the
following way.
resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
getCustomerHeader());
public Collection<Header> getCustomerHeader() throws
Exception {
SoapHeader sh_client_id=null;
SoapHeader sh_dev_pass=null;
SoapHeader sh_dev_email=null;
try {
Document d = createXMLDocument();
Element dev_email =
d.createElement("developer_email");
dev_email.setTextContent("......");
sh_dev_email = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
dev_email);
Element dev_pass =
d.createElement("developer_password");
dev_pass.setTextContent("......");
sh_dev_pass = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
dev_pass);
Element client_id =
d.createElement("client_id");
client_id.setTextContent("......");
sh_client_id = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
client_id);
}catch(Exception e) {
throw new
Exception(e.getMessage(), new
Throwable(e));
}
List<Header> lshd = new
ArrayList<Header>();
lshd.add(sh_dev_email);
lshd.add(sh_dev_pass);
lshd.add(sh_client_id);
return lshd;
}
Regards
Raman
-----Original Message-----
From: Anand R [mailto:Anand.Raman@ibsplc.com]
Sent: Friday, February 18, 2011 3:58 PM
To: users@cxf.apache.org
Subject: Query - Setting a custom HTTP request header
Hi,
Is there a way to set a custom HTTP request header from a CXF client?
Thanks and regards,
Anand R
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or
any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
RE: Query - Setting a custom HTTP request header
Posted by "Malisetti, Ramanjaneyulu" <Ra...@ca.com>.
How the client is created. If it is through Dispatch. You can do the
following way.
resourceDispatch.getRequestContext().put(Header.HEADER_LIST,
getCustomerHeader());
public Collection<Header> getCustomerHeader() throws Exception {
SoapHeader sh_client_id=null;
SoapHeader sh_dev_pass=null;
SoapHeader sh_dev_email=null;
try {
Document d = createXMLDocument();
Element dev_email =
d.createElement("developer_email");
dev_email.setTextContent("......");
sh_dev_email = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
dev_email);
Element dev_pass =
d.createElement("developer_password");
dev_pass.setTextContent("......");
sh_dev_pass = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
dev_pass);
Element client_id = d.createElement("client_id");
client_id.setTextContent("......");
sh_client_id = new SoapHeader(new
QName("http://www.google.com/api/adsense/v2", "AccountServiceService"),
client_id);
}catch(Exception e) {
throw new Exception(e.getMessage(), new
Throwable(e));
}
List<Header> lshd = new ArrayList<Header>();
lshd.add(sh_dev_email);
lshd.add(sh_dev_pass);
lshd.add(sh_client_id);
return lshd;
}
Regards
Raman
-----Original Message-----
From: Anand R [mailto:Anand.Raman@ibsplc.com]
Sent: Friday, February 18, 2011 3:58 PM
To: users@cxf.apache.org
Subject: Query - Setting a custom HTTP request header
Hi,
Is there a way to set a custom HTTP request header from a CXF client?
Thanks and regards,
Anand R
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or
any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."