You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@synapse.apache.org by J Bouck <bo...@gmail.com> on 2007/09/19 22:28:06 UTC

Generate SOAP Faults from Class Mediator possible?

In synapse 1.0, I am using a custom class mediator in the inSequence
of a proxy service.  How do I generate a SOAP fault from the custom
class mediator?  Returning false in the class mediator doesn't seem to
do trigger the faultSequence for the proxy service.  Throwing
exceptions in the class mediator doesn't seem to trigger the
faultSequence either.  I can get the proxy service fault Sequence to
run only if the in Sequence "send" fails, never with the custom class
mediator that precedes the "send".  I have looked at sample 510 that
describes what the synapse.xmlneeds to look like for custom class
mediators, but I can't get that example to generate a SOAP Fault
either.  Do I need to write directly to the Synapse MessageContext in
the mediator?
~john

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Generate SOAP Faults from Class Mediator possible?

Posted by "Asankha C. Perera" <as...@wso2.com>.
Hi John
> I decided to throw a SynapseException directly in the
> custom mediator class and it works just right for me.  I get a
> properly formatted SOAP Fault.
Cool.. but I think it would be better for the class (and the new POJO 
command) mediator to catch any exception from a custom class invocation 
and then convert this into a Synapse exception so that the scenario is 
handled better automatically. It'll be great if you can raise this JIRA 
as the user who came across this issue and we will gladly fix it for the 
1.1 release

asankha


---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Generate SOAP Faults from Class Mediator possible?

Posted by J Bouck <bo...@gmail.com>.
Thanks for the speedy reply.  I guess that I was caught up in the
mediate method returning a boolean (returning false doesn't seem to do
anything).  I decided to throw a SynapseException directly in the
custom mediator class and it works just right for me.  I get a
properly formatted SOAP Fault.  I looked at the source of the
validation mediator for inspiration on how it should be done (ala
handleException method).
If there isn't a fault sequence explicitly defined for the proxy
service, then synapse looks for the sequence named "fault" outside of
the proxy service configuration.  The makefault works just fine.
Synapse continues to impress.  Looking forward to 1.1 features upon its release.
~john


On 9/19/07, Paul Fremantle <pz...@gmail.com> wrote:
> John
>
> You can use the makefault mediator to do this.
>
> <makefault [version="soap11|soap12"]>
>   <code (value="literal" | expression="xpath")/>
>   <reason (value="literal" | expression="xpath")>
>   <node>?
>   <role>?
>   <detail>?
>  </makefault>
>
> See sample 5
> http://ws.apache.org/synapse/Synapse_Samples.html#Sample5
>
> If you throw an exception from your mediator, that should trigger
> synapse to use the sequence named "fault":
> see http://ws.apache.org/synapse/Synapse_Samples.html#Sample4
>
> Paul
>
> On 9/19/07, J Bouck <bo...@gmail.com> wrote:
> > In synapse 1.0, I am using a custom class mediator in the inSequence
> > of a proxy service.  How do I generate a SOAP fault from the custom
> > class mediator?  Returning false in the class mediator doesn't seem to
> > do trigger the faultSequence for the proxy service.  Throwing
> > exceptions in the class mediator doesn't seem to trigger the
> > faultSequence either.  I can get the proxy service fault Sequence to
> > run only if the in Sequence "send" fails, never with the custom class
> > mediator that precedes the "send".  I have looked at sample 510 that
> > describes what the synapse.xmlneeds to look like for custom class
> > mediators, but I can't get that example to generate a SOAP Fault
> > either.  Do I need to write directly to the Synapse MessageContext in
> > the mediator?
> > ~john
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: synapse-user-help@ws.apache.org
> >
> >
>
>
> --
> Paul Fremantle
> Co-Founder and VP of Technical Sales, WSO2
> OASIS WS-RX TC Co-chair
>
> blog: http://pzf.fremantle.org
> paul@wso2.com
>
> "Oxygenating the Web Service Platform", www.wso2.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org


Re: Generate SOAP Faults from Class Mediator possible?

Posted by Paul Fremantle <pz...@gmail.com>.
John

You can use the makefault mediator to do this.

<makefault [version="soap11|soap12"]>
   <code (value="literal" | expression="xpath")/>
   <reason (value="literal" | expression="xpath")>
   <node>?
   <role>?
   <detail>?
 </makefault>

See sample 5
http://ws.apache.org/synapse/Synapse_Samples.html#Sample5

If you throw an exception from your mediator, that should trigger
synapse to use the sequence named "fault":
see http://ws.apache.org/synapse/Synapse_Samples.html#Sample4

Paul

On 9/19/07, J Bouck <bo...@gmail.com> wrote:
> In synapse 1.0, I am using a custom class mediator in the inSequence
> of a proxy service.  How do I generate a SOAP fault from the custom
> class mediator?  Returning false in the class mediator doesn't seem to
> do trigger the faultSequence for the proxy service.  Throwing
> exceptions in the class mediator doesn't seem to trigger the
> faultSequence either.  I can get the proxy service fault Sequence to
> run only if the in Sequence "send" fails, never with the custom class
> mediator that precedes the "send".  I have looked at sample 510 that
> describes what the synapse.xmlneeds to look like for custom class
> mediators, but I can't get that example to generate a SOAP Fault
> either.  Do I need to write directly to the Synapse MessageContext in
> the mediator?
> ~john
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-user-help@ws.apache.org
>
>


-- 
Paul Fremantle
Co-Founder and VP of Technical Sales, WSO2
OASIS WS-RX TC Co-chair

blog: http://pzf.fremantle.org
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com

---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-user-help@ws.apache.org