You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alexandre N <al...@sgcib.com> on 2009/07/08 19:39:10 UTC
Add a field in http headers does not work?
Hi,
I want to add a field in http header (not in soap header).
I did a out interceptor.
public class MyOutInterceptor extends AbstractSoapInterceptor
{
public MyOutInterceptor()
{
super(Phase.POST_LOGICAL);
}
@Override
public void handleMessage(final SoapMessage message) throws Fault
{
System.out.println("MyOutInterceptor.handle soapMessage=" +
message);
message.put("token", "tokenValue");
message.put("SOAPAction", "action2");
}
}
It is quite weird because SOAPAction is correct to action2 but token is not
added.
I suppose is because it was present before but I don't know why.
I tried others phases but without success.
If someone has a solution.
--
View this message in context: http://www.nabble.com/Add-a-field-in-http-headers-does-not-work--tp24396137p24396137.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Add a field in http headers does not work?
Posted by Alexandre N <al...@sgcib.com>.
I tried before but it did not work.
I realised I was in the wrong phase (I must be in write phase) and now it
works.
So thanks a lot and I think it can be useful for users to detail what you
can (or cannot do) in the different phases in the documentation.
Alexandre
dkulp wrote:
>
>
> You need to get the protocol headers map out of the message and put your
> stuff
> there. The "get/put" stuff on the message is for storage of stuff
> related to
> processing the message. That includes stuff that would not be protocol
> headers.
> Map<String, List<String>> reqHeaders =
> CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS));
> if (reqHeaders == null) {
> reqHeaders = new HashMap<String, List<String>>();
> message.put(Message.PROTOCOL_HEADERS, reqHeaders);
> }
>
> ....
>
> Dan
>
>
> On Wed July 8 2009 1:39:10 pm Alexandre N wrote:
>> Hi,
>>
>> I want to add a field in http header (not in soap header).
>>
>> I did a out interceptor.
>>
>> public class MyOutInterceptor extends AbstractSoapInterceptor
>> {
>>
>> public MyOutInterceptor()
>> {
>> super(Phase.POST_LOGICAL);
>> }
>>
>>
>> @Override
>> public void handleMessage(final SoapMessage message) throws Fault
>> {
>> System.out.println("MyOutInterceptor.handle soapMessage=" +
>> message);
>> message.put("token", "tokenValue");
>> message.put("SOAPAction", "action2");
>> }
>> }
>>
>> It is quite weird because SOAPAction is correct to action2 but token is
>> not
>> added.
>> I suppose is because it was present before but I don't know why.
>> I tried others phases but without success.
>>
>> If someone has a solution.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
--
View this message in context: http://www.nabble.com/Add-a-field-in-http-headers-does-not-work--tp24396137p24397540.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Add a field in http headers does not work?
Posted by Daniel Kulp <dk...@apache.org>.
You need to get the protocol headers map out of the message and put your stuff
there. The "get/put" stuff on the message is for storage of stuff related to
processing the message. That includes stuff that would not be protocol
headers.
Map<String, List<String>> reqHeaders =
CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS));
if (reqHeaders == null) {
reqHeaders = new HashMap<String, List<String>>();
message.put(Message.PROTOCOL_HEADERS, reqHeaders);
}
....
Dan
On Wed July 8 2009 1:39:10 pm Alexandre N wrote:
> Hi,
>
> I want to add a field in http header (not in soap header).
>
> I did a out interceptor.
>
> public class MyOutInterceptor extends AbstractSoapInterceptor
> {
>
> public MyOutInterceptor()
> {
> super(Phase.POST_LOGICAL);
> }
>
>
> @Override
> public void handleMessage(final SoapMessage message) throws Fault
> {
> System.out.println("MyOutInterceptor.handle soapMessage=" +
> message);
> message.put("token", "tokenValue");
> message.put("SOAPAction", "action2");
> }
> }
>
> It is quite weird because SOAPAction is correct to action2 but token is not
> added.
> I suppose is because it was present before but I don't know why.
> I tried others phases but without success.
>
> If someone has a solution.
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: Add a field in http headers does not work?
Posted by Glen Mazza <gl...@gmail.com>.
I think the BindingProvider will do what you want, see Step #7 here:
http://www.jroller.com/gmazza/entry/setting_up_ssl_and_basic
Or the Metro guide here:
https://metro.dev.java.net/guide/HTTP_headers.html
I'm unsure how to do this within an interceptor, however.
HTH,
Glen
Alexandre N wrote:
>
> Hi,
>
> I want to add a field in http header (not in soap header).
>
> I did a out interceptor.
>
> public class MyOutInterceptor extends AbstractSoapInterceptor
> {
>
> public MyOutInterceptor()
> {
> super(Phase.POST_LOGICAL);
> }
>
>
> @Override
> public void handleMessage(final SoapMessage message) throws Fault
> {
> System.out.println("MyOutInterceptor.handle soapMessage=" +
> message);
> message.put("token", "tokenValue");
> message.put("SOAPAction", "action2");
> }
> }
>
> It is quite weird because SOAPAction is correct to action2 but token is
> not added.
> I suppose is because it was present before but I don't know why.
> I tried others phases but without success.
>
> If someone has a solution.
>
>
--
View this message in context: http://www.nabble.com/Add-a-field-in-http-headers-does-not-work--tp24396137p24397207.html
Sent from the cxf-user mailing list archive at Nabble.com.