You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ronald Pieterse <ro...@gmail.com> on 2010/06/02 09:30:03 UTC
Replace Fault with custom response
Hi,
I would like to replace all Faults with my own response object to keep the
Faults from my clients. So I mean not wrap them into another object but
really replace the Fault object with my own Response.
What would be the best way to do this? I read something about extending the
JAXWSMethodInvoker but its not clear how that should work for me.
Should I replace some interceptors on the outgoing chain?
Can someone help me out here?
Ronald
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28751052.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Replace Fault with custom response
Posted by Ronald Pieterse <ro...@gmail.com>.
Ok got a little further. I found out that the defaultContent can be set if
you add a List to the message content like so:
message.setContent(List.class, Arrays.asList(new String[] { "result" }));
Now I run into another problem that I described in another thread:
http://old.nabble.com/Response-object-is-null-td28859579.html
Thanx so far.
Ronald
Ronald Pieterse wrote:
>
> In the mean time I've been playing with an interceptor trying to do the
> thing I want and I succeeded in removing the Exception from the response.
> Now I also tried to put some new content (a string) in the message but
> that does not go well. When I debug I see that the Exception resided in
> the 'defaultContent' property of the message and when I put something in
> the message it resides in the 'content' of the message. Thus it does not
> appear in my response at all - the soap body remains empty.
>
> I can not find any setter for this property. How does this work? And is
> this a good way anyway to handle this kind of stuff or would you recommend
> using the invoker strategy?
>
> Thanx.
> Ronald
>
>
> dkulp wrote:
>>
>>
>> Hmm... can you package up a small test case. Not sure what is going on.
>> Could be a classloader issue, but I'm not sure.
>>
>> For the constructor, I would pass the impl bean of your service. That
>> would
>> be the "default" that the normal factory would end up doing.
>>
>> Dan
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28860665.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Replace Fault with custom response
Posted by Ronald Pieterse <ro...@gmail.com>.
In the mean time I've been playing with an interceptor trying to do the thing
I want and I succeeded in removing the Exception from the response. Now I
also tried to put some new content (a string) in the message but that does
not go well. When I debug I see that the Exception resided in the
'defaultContent' property of the message and when I put something in the
message it resides in the 'content' of the message. Thus it does not appear
in my response at all - the soap body remains empty.
I can not find any setter for this property. How does this work? And is this
a good way anyway to handle this kind of stuff or would you recommend using
the invoker strategy?
Thanx.
Ronald
dkulp wrote:
>
>
> Hmm... can you package up a small test case. Not sure what is going on.
> Could be a classloader issue, but I'm not sure.
>
> For the constructor, I would pass the impl bean of your service. That
> would
> be the "default" that the normal factory would end up doing.
>
> Dan
>
>
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28814300.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Replace Fault with custom response
Posted by Daniel Kulp <dk...@apache.org>.
Hmm... can you package up a small test case. Not sure what is going on.
Could be a classloader issue, but I'm not sure.
For the constructor, I would pass the impl bean of your service. That would
be the "default" that the normal factory would end up doing.
Dan
On Sunday 06 June 2010 6:04:44 pm Ronald Pieterse wrote:
> Hi Dan,
>
> When I use my custom MessageInvoker and make my service call I get the
> following exception:
>
> "org.apache.cxf.interceptor.Fault: object is not an instance of declaring
> class while invoking public java.lang.String
> com.tripolis.services.impl.PrototypeServiceImpl.rerouting(java.lang.Integer
> ) with params [3]"
>
> The custom invoker has no specific implementation yet; just the call to
> super. So actually nothing custom really...
> If I take the jaxws:invoker out in the spring config, the call works fine.
> The service call is very simple - just an Integer input value and a String
> output value.
>
> Because I use Spring I had to add a default constructor in my custom
> MessageInvoker. Could that be the problem? That the wrong constructor is
> called on initialization? Or should I add constructor-arg in the spring
> config for my custom invoker? If so, which implementation of Factory should
> I then use?
>
> Ronald
>
> dkulp wrote:
> > Basically, you would subclass the JAXWSMethodInvoker and override the
> > invoke
> > method to catch the Faults and then have it return your normal response
> > object. In the spring config, the jaxws:endpoint element has a
> > jaxws:invoker child element that would be an instance of your invoker.
> > Something like:
> >
> > <jaxws:endpoint .....>
> >
> > <jaxws:invoker><bean class="com.foo.MyInvoker"/></jaxws:invoker>
> >
> > </jaxws:endpoint>
> >
> >
> > Dan
> >
> > On Wednesday 02 June 2010 3:30:03 am Ronald Pieterse wrote:
> >> Hi,
> >>
> >> I would like to replace all Faults with my own response object to keep
> >> the
> >> Faults from my clients. So I mean not wrap them into another object but
> >> really replace the Fault object with my own Response.
> >> What would be the best way to do this? I read something about extending
> >> the
> >> JAXWSMethodInvoker but its not clear how that should work for me.
> >> Should I replace some interceptors on the outgoing chain?
> >> Can someone help me out here?
> >>
> >> Ronald
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Replace Fault with custom response
Posted by Ronald Pieterse <ro...@gmail.com>.
Hi Dan,
When I use my custom MessageInvoker and make my service call I get the
following exception:
"org.apache.cxf.interceptor.Fault: object is not an instance of declaring
class while invoking public java.lang.String
com.tripolis.services.impl.PrototypeServiceImpl.rerouting(java.lang.Integer)
with params [3]"
The custom invoker has no specific implementation yet; just the call to
super. So actually nothing custom really...
If I take the jaxws:invoker out in the spring config, the call works fine.
The service call is very simple - just an Integer input value and a String
output value.
Because I use Spring I had to add a default constructor in my custom
MessageInvoker. Could that be the problem? That the wrong constructor is
called on initialization? Or should I add constructor-arg in the spring
config for my custom invoker? If so, which implementation of Factory should
I then use?
Ronald
dkulp wrote:
>
>
> Basically, you would subclass the JAXWSMethodInvoker and override the
> invoke
> method to catch the Faults and then have it return your normal response
> object. In the spring config, the jaxws:endpoint element has a
> jaxws:invoker child element that would be an instance of your invoker.
> Something like:
>
> <jaxws:endpoint .....>
> <jaxws:invoker><bean class="com.foo.MyInvoker"/></jaxws:invoker>
> </jaxws:endpoint>
>
>
> Dan
>
>
> On Wednesday 02 June 2010 3:30:03 am Ronald Pieterse wrote:
>> Hi,
>>
>> I would like to replace all Faults with my own response object to keep
>> the
>> Faults from my clients. So I mean not wrap them into another object but
>> really replace the Fault object with my own Response.
>> What would be the best way to do this? I read something about extending
>> the
>> JAXWSMethodInvoker but its not clear how that should work for me.
>> Should I replace some interceptors on the outgoing chain?
>> Can someone help me out here?
>>
>> Ronald
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
>
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28793396.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Replace Fault with custom response
Posted by Ronald Pieterse <ro...@gmail.com>.
I tried using the MessageInvoker earlier but was focussing on the createFault
methods. Now when I try to inject my custom MessageInvoker I get the
following exception:
"org.apache.cxf.interceptor.Fault: object is not an instance of declaring
class while invoking public java.lang.String
com.tripolis.services.impl.PrototypeServiceImpl.rerouting(java.lang.Integer)
with params [3]"
This happens as soon as I use jaxws:invoker. There is no implementation of
the invoke method whatsoever besides a call to super. If I take the
jaxws:invoker out the call works fine.
The service call is very simple - just an Integer input value and a String
output value.
Because I use Spring I had to add a default constructor in my custom
MessageInvoker. Could that be the problem? That the wrong constructor is
called on initialization?
dkulp wrote:
>
>
> Basically, you would subclass the JAXWSMethodInvoker and override the
> invoke
> method to catch the Faults and then have it return your normal response
> object. In the spring config, the jaxws:endpoint element has a
> jaxws:invoker child element that would be an instance of your invoker.
> Something like:
>
> <jaxws:endpoint .....>
> <jaxws:invoker><bean class="com.foo.MyInvoker"/></jaxws:invoker>
> </jaxws:endpoint>
>
>
> Dan
>
>
> On Wednesday 02 June 2010 3:30:03 am Ronald Pieterse wrote:
>> Hi,
>>
>> I would like to replace all Faults with my own response object to keep
>> the
>> Faults from my clients. So I mean not wrap them into another object but
>> really replace the Fault object with my own Response.
>> What would be the best way to do this? I read something about extending
>> the
>> JAXWSMethodInvoker but its not clear how that should work for me.
>> Should I replace some interceptors on the outgoing chain?
>> Can someone help me out here?
>>
>> Ronald
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>
>
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28793181.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Replace Fault with custom response
Posted by Daniel Kulp <dk...@apache.org>.
Basically, you would subclass the JAXWSMethodInvoker and override the invoke
method to catch the Faults and then have it return your normal response
object. In the spring config, the jaxws:endpoint element has a
jaxws:invoker child element that would be an instance of your invoker.
Something like:
<jaxws:endpoint .....>
<jaxws:invoker><bean class="com.foo.MyInvoker"/></jaxws:invoker>
</jaxws:endpoint>
Dan
On Wednesday 02 June 2010 3:30:03 am Ronald Pieterse wrote:
> Hi,
>
> I would like to replace all Faults with my own response object to keep the
> Faults from my clients. So I mean not wrap them into another object but
> really replace the Fault object with my own Response.
> What would be the best way to do this? I read something about extending the
> JAXWSMethodInvoker but its not clear how that should work for me.
> Should I replace some interceptors on the outgoing chain?
> Can someone help me out here?
>
> Ronald
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: Replace Fault with custom response
Posted by Glen Mazza <gl...@gmail.com>.
Within the outbound error handling interceptor chain you can probably modify
the response via SAAJ or DOM to change the SOAP fault to a SOAP response
object. Still, though, the fault handling system is defined with the JAX-WS
specification and is precisely what SOAP clients should be expecting. I'm
not sure what would be gained by leaving the standard.
Glen
Ronald Pieterse wrote:
>
> Hi,
>
> I would like to replace all Faults with my own response object to keep the
> Faults from my clients. So I mean not wrap them into another object but
> really replace the Fault object with my own Response.
> What would be the best way to do this? I read something about extending
> the JAXWSMethodInvoker but its not clear how that should work for me.
> Should I replace some interceptors on the outgoing chain?
> Can someone help me out here?
>
> Ronald
>
>
--
View this message in context: http://old.nabble.com/Replace-Fault-with-custom-response-tp28751052p28756991.html
Sent from the cxf-user mailing list archive at Nabble.com.