Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Hello,

I'm trying to set a header in the SOAP response of all my calls.This header
must just contain the version of my service implementation. I'm trying to do
this using an OUT interceptor (extends AbstractSoapInterceptor) which is
defined in my spring file:













The interceptor kicks in alright when I go back to the client but it's
unclear which Phase I need to be in to add the header and also how to set
the header. Do I just get the headers (btw there are no response headers
available - is that correct?) and then add one to the list like this:


soapMsg.getHeaders().add(new Header(new
QName("http://some.namespace";), "api.version=1.7"));


I suspect that the way I set this header is not entirely correct :-) I could
use some help here. THNX

-- 
View this message in context: 
http://www.nabble.com/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13426234
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ulhas Bhole


Are you checking for the DOM elements? Don't expect to see it in string 
format.


you need to get the handle onto the Header list and go through the list 
to check the DOM elements and you would find it there.


Sorry, didn;t read the complete message it looks like your interceptor 
kicks in after the header processing is done. If you have no dependency 
on any interceptors to be finished you can add it before Phase.WRITE.


you can add following lines to your interceptor's constructor and it 
should make sure that the interceptor gets called before the header 
processing happens.


super(Phase.WRITE);
addBefore(SoapOutInterceptor.class.getName());


Regards,

Ulhas

Ronald Pieterse wrote:

Right, The header I'm setting is not appearing when I check the response in
e.g. SoapUI. The only requirement I have is that I would like to see the
header in my response one way or the other :-)
I also have a System.out.println in my interceptor so I know it kicks in and
no exceptions are thrown so I wonder where the header went...
The response looks like this:

http://schemas.xmlsoap.org/soap/envelope/";>
   
  http://some.namespace/";>
 
  ...
 
  
   



As you can see there's no headers available at all. Any ideas?


Ulhas Bhole wrote:
  

Hi Roland,

It's upto your requirement at which phase it should be added. I don't 
see any problem in the way you are setting header. Do you mean to say 
that interceptor kicks in but you don't see soap header other side?


Regards,

Ulhas Bhole

Ronald Pieterse wrote:


Hello,

I'm trying to set a header in the SOAP response of all my calls.This
header
must just contain the version of my service implementation. I'm trying to
do
this using an OUT interceptor (extends AbstractSoapInterceptor) which is
defined in my spring file:













The interceptor kicks in alright when I go back to the client but it's
unclear which Phase I need to be in to add the header and also how to set
the header. Do I just get the headers (btw there are no response headers
available - is that correct?) and then add one to the list like this:


soapMsg.getHeaders().add(new Header(new
QName("http://some.namespace";), "api.version=1.7"));


I suspect that the way I set this header is not entirely correct :-) I
could
use some help here. THNX

  
  


IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland





  



IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland


Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ulhas Bhole

Hi Roland,

It's upto your requirement at which phase it should be added. I don't 
see any problem in the way you are setting header. Do you mean to say 
that interceptor kicks in but you don't see soap header other side?


Regards,

Ulhas Bhole

Ronald Pieterse wrote:

Hello,

I'm trying to set a header in the SOAP response of all my calls.This header
must just contain the version of my service implementation. I'm trying to do
this using an OUT interceptor (extends AbstractSoapInterceptor) which is
defined in my spring file:













The interceptor kicks in alright when I go back to the client but it's
unclear which Phase I need to be in to add the header and also how to set
the header. Do I just get the headers (btw there are no response headers
available - is that correct?) and then add one to the list like this:


soapMsg.getHeaders().add(new Header(new
QName("http://some.namespace";), "api.version=1.7"));


I suspect that the way I set this header is not entirely correct :-) I could
use some help here. THNX

  



IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland


Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Ok, at least it seems to respond now but I get a ClassCast exception on the
Object I try to put in the header. I try to do something like this:

soapMsg.getHeaders().add(new Header(new QName("http://api.tripolis.com";),
"version=2.0"));

for (Header header : soapMsg.getHeaders()) {
 System.out.println("header: " + header.getName());
}

After setting the header I read it out of the message and it looks alright
but further on the exception is thrown like this:

[16:04:59.764] Interceptor has thrown exception, unwinding now
[16:04:59.764] java.lang.ClassCastException: java.lang.String
[16:04:59.764]  at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:120)
...

I'm almost there - I can feel it...


Ulhas Bhole wrote:
> 
> 
> Are you checking for the DOM elements? Don't expect to see it in string 
> format.
> 
> you need to get the handle onto the Header list and go through the list 
> to check the DOM elements and you would find it there.
> 
> Sorry, didn;t read the complete message it looks like your interceptor 
> kicks in after the header processing is done. If you have no dependency 
> on any interceptors to be finished you can add it before Phase.WRITE.
> 
> you can add following lines to your interceptor's constructor and it 
> should make sure that the interceptor gets called before the header 
> processing happens.
> 
> super(Phase.WRITE);
> addBefore(SoapOutInterceptor.class.getName());
> 
> 
> Regards,
> 
> Ulhas
> 
> Ronald Pieterse wrote:
>> Right, The header I'm setting is not appearing when I check the response
>> in
>> e.g. SoapUI. The only requirement I have is that I would like to see the
>> header in my response one way or the other :-)
>> I also have a System.out.println in my interceptor so I know it kicks in
>> and
>> no exceptions are thrown so I wonder where the header went...
>> The response looks like this:
>>
>> http://schemas.xmlsoap.org/soap/envelope/";>
>>
>>   http://some.namespace/";>
>>  
>>   ...
>>  
>>   
>>
>> 
>>
>>
>> As you can see there's no headers available at all. Any ideas?
>>
>>
>> Ulhas Bhole wrote:
>>   
>>> Hi Roland,
>>>
>>> It's upto your requirement at which phase it should be added. I don't 
>>> see any problem in the way you are setting header. Do you mean to say 
>>> that interceptor kicks in but you don't see soap header other side?
>>>
>>> Regards,
>>>
>>> Ulhas Bhole
>>>
>>> Ronald Pieterse wrote:
>>> 
>>>> Hello,
>>>>
>>>> I'm trying to set a header in the SOAP response of all my calls.This
>>>> header
>>>> must just contain the version of my service implementation. I'm trying
>>>> to
>>>> do
>>>> this using an OUT interceptor (extends AbstractSoapInterceptor) which
>>>> is
>>>> defined in my spring file:
>>>>
>>>>
>>>> >>>class="my.package.SoapHeaderSetter" />
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> The interceptor kicks in alright when I go back to the client but it's
>>>> unclear which Phase I need to be in to add the header and also how to
>>>> set
>>>> the header. Do I just get the headers (btw there are no response
>>>> headers
>>>> available - is that correct?) and then add one to the list like this:
>>>>
>>>>
>>>> soapMsg.getHeaders().add(new Header(new
>>>> QName("http://some.namespace";), "api.version=1.7"));
>>>>
>>>>
>>>> I suspect that the way I set this header is not entirely correct :-) I
>>>> could
>>>> use some help here. THNX
>>>>
>>>>   
>>>>   
>>> 
>>> IONA Technologies PLC (registered in Ireland)
>>> Registered Number: 171387
>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>> Ireland
>>>
>>>
>>> 
>>
>>   
> 
> 
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13428076
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse

Right, The header I'm setting is not appearing when I check the response in
e.g. SoapUI. The only requirement I have is that I would like to see the
header in my response one way or the other :-)
I also have a System.out.println in my interceptor so I know it kicks in and
no exceptions are thrown so I wonder where the header went...
The response looks like this:

http://schemas.xmlsoap.org/soap/envelope/";>
   
  http://some.namespace/";>
 
  ...
 
  
   



As you can see there's no headers available at all. Any ideas?


Ulhas Bhole wrote:
> 
> Hi Roland,
> 
> It's upto your requirement at which phase it should be added. I don't 
> see any problem in the way you are setting header. Do you mean to say 
> that interceptor kicks in but you don't see soap header other side?
> 
> Regards,
> 
> Ulhas Bhole
> 
> Ronald Pieterse wrote:
>> Hello,
>>
>> I'm trying to set a header in the SOAP response of all my calls.This
>> header
>> must just contain the version of my service implementation. I'm trying to
>> do
>> this using an OUT interceptor (extends AbstractSoapInterceptor) which is
>> defined in my spring file:
>>
>>
>> >  class="my.package.SoapHeaderSetter" />
>>
>>  
>>  
>>  
>>  
>>  
>>  
>>  
>>
>>
>> The interceptor kicks in alright when I go back to the client but it's
>> unclear which Phase I need to be in to add the header and also how to set
>> the header. Do I just get the headers (btw there are no response headers
>> available - is that correct?) and then add one to the list like this:
>>
>>
>> soapMsg.getHeaders().add(new Header(new
>> QName("http://some.namespace";), "api.version=1.7"));
>>
>>
>> I suspect that the way I set this header is not entirely correct :-) I
>> could
>> use some help here. THNX
>>
>>   
> 
> 
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13427417
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ulhas Bhole

Hi Ronald,

I take back my statement from first mail that the header you are setting 
is ok. I had a quick look through the code.


Header expects the data binding that can marshal the header object you 
set or if no databinding specified then the DOM element.
So, instead of adding simple string create a DOM element and add the DOM 
element to the header and you should see the exception disappearing.


Regards,

Ulhas Bhole

Ronald Pieterse wrote:

Ok, at least it seems to respond now but I get a ClassCast exception on the
Object I try to put in the header. I try to do something like this:

soapMsg.getHeaders().add(new Header(new QName("http://api.tripolis.com";),
"version=2.0"));

for (Header header : soapMsg.getHeaders()) {
 System.out.println("header: " + header.getName());
}

After setting the header I read it out of the message and it looks alright
but further on the exception is thrown like this:

[16:04:59.764] Interceptor has thrown exception, unwinding now
[16:04:59.764] java.lang.ClassCastException: java.lang.String
[16:04:59.764]  at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:120)
...

I'm almost there - I can feel it...


Ulhas Bhole wrote:
  
Are you checking for the DOM elements? Don't expect to see it in string 
format.


you need to get the handle onto the Header list and go through the list 
to check the DOM elements and you would find it there.


Sorry, didn;t read the complete message it looks like your interceptor 
kicks in after the header processing is done. If you have no dependency 
on any interceptors to be finished you can add it before Phase.WRITE.


you can add following lines to your interceptor's constructor and it 
should make sure that the interceptor gets called before the header 
processing happens.


super(Phase.WRITE);
addBefore(SoapOutInterceptor.class.getName());


Regards,

Ulhas

Ronald Pieterse wrote:


Right, The header I'm setting is not appearing when I check the response
in
e.g. SoapUI. The only requirement I have is that I would like to see the
header in my response one way or the other :-)
I also have a System.out.println in my interceptor so I know it kicks in
and
no exceptions are thrown so I wonder where the header went...
The response looks like this:

http://schemas.xmlsoap.org/soap/envelope/";>
   
  http://some.namespace/";>
 
  ...
 
  
   



As you can see there's no headers available at all. Any ideas?


Ulhas Bhole wrote:
  
  

Hi Roland,

It's upto your requirement at which phase it should be added. I don't 
see any problem in the way you are setting header. Do you mean to say 
that interceptor kicks in but you don't see soap header other side?


Regards,

Ulhas Bhole

Ronald Pieterse wrote:



Hello,

I'm trying to set a header in the SOAP response of all my calls.This
header
must just contain the version of my service implementation. I'm trying
to
do
this using an OUT interceptor (extends AbstractSoapInterceptor) which
is
defined in my spring file:













The interceptor kicks in alright when I go back to the client but it's
unclear which Phase I need to be in to add the header and also how to
set
the header. Do I just get the headers (btw there are no response
headers
available - is that correct?) and then add one to the list like this:


soapMsg.getHeaders().add(new Header(new
QName("http://some.namespace";), "api.version=1.7"));


I suspect that the way I set this header is not entirely correct :-) I
could
use some help here. THNX

  
  
  


IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
Ireland




  
  


IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland





  



IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland


Re: Setting SOAP header in SOAP response

2007-10-26 Thread Ronald Pieterse
t;>> I'm trying to set a header in the SOAP response of all my calls.This
>>>>>> header
>>>>>> must just contain the version of my service implementation. I'm
>>>>>> trying
>>>>>> to
>>>>>> do
>>>>>> this using an OUT interceptor (extends AbstractSoapInterceptor) which
>>>>>> is
>>>>>> defined in my spring file:
>>>>>>
>>>>>>
>>>>>> >>>>>  class="my.package.SoapHeaderSetter" />
>>>>>>
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>      
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>
>>>>>>
>>>>>> The interceptor kicks in alright when I go back to the client but
>>>>>> it's
>>>>>> unclear which Phase I need to be in to add the header and also how to
>>>>>> set
>>>>>> the header. Do I just get the headers (btw there are no response
>>>>>> headers
>>>>>> available - is that correct?) and then add one to the list like this:
>>>>>>
>>>>>>
>>>>>> soapMsg.getHeaders().add(new Header(new
>>>>>> QName("http://some.namespace";), "api.version=1.7"));
>>>>>>
>>>>>>
>>>>>> I suspect that the way I set this header is not entirely correct :-)
>>>>>> I
>>>>>> could
>>>>>> use some help here. THNX
>>>>>>
>>>>>>   
>>>>>>   
>>>>>>   
>>>>> 
>>>>> IONA Technologies PLC (registered in Ireland)
>>>>> Registered Number: 171387
>>>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>>>> Ireland
>>>>>
>>>>>
>>>>> 
>>>>> 
>>>>   
>>>>   
>>> 
>>> IONA Technologies PLC (registered in Ireland)
>>> Registered Number: 171387
>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>> Ireland
>>>
>>>
>>> 
>>
>>   
> 
> 
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Setting-SOAP-header-in-SOAP-response-tf4697009.html#a13428591
Sent from the cxf-user mailing list archive at Nabble.com.