You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Eric Dofonsou <ew...@yahoo.com> on 2006/05/04 21:35:51 UTC

Issue in the way servicemix handle soap errors

Hello,

I am having another issue with the way servicemix
handles all the soap fault message return by my web
services,

With the current version of servicemix, my soap
message is replace by the following HTTP error message
:
------
<html>
   <head>
      <title>Error 500 Unknown Error</title>
   </head>
   <body>
      <h2>HTTP ERROR: 500</h2>
      <pre>Unknown Error</pre>
      <p>RequestURI=/Service/</p>
      <p>
         <i>
            <small>
               <a
href="http://jetty.mortbay.org">Powered by
Jetty://</a>
            </small>
         </i>
      </p>
   </body>
</html>
----

because of this message, my generated stubs cannot
properly handle the soap message.

I was wondering if it's not possible to have an
attribut that specifies on a provider endpoint that we
do not want servicemix to error message from the web
service and just return them as is to the client.

PS : when I put the block of code that handls the
error message in comment it works fine :
Here is the black of code from ProviderProcessor that
is commented out :
------------
            if (response != HttpStatus.SC_OK) {
                if (exchange instanceof InOnly ==
false) {
                    Fault fault =
exchange.createFault();
                    SoapReader reader =
soapMarshaler.createReader();
                    Header contentType =
method.getResponseHeader("Content-Type");
                    soapMessage =
reader.read(method.getResponseBodyAsStream(), 
                                             
contentType != null ? contentType.getValue() : null);
                   
fault.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(method));
                    jbiMarshaler.toNMS(fault,
soapMessage);
                    exchange.setFault(fault);
                   
exchange.setStatus(ExchangeStatus.ERROR);
                    channel.send(exchange);
                    return;
                } else {
                    throw new Exception("Invalid
status response: " + response);
                }
            }
------------

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Issue in the way servicemix handle soap errors

Posted by cheff <st...@gmail.com>.
Hi

I saw your messages and the JIRA SM-433 but ... the fix does not work for
me.
For me, the web service exceptions should be handled from a SOAP Fault
Handler. For me the only correct response of a SOAP Request is a SOAP
Response (with Fault or not). If I need HTTP Error Message I should
implement my service not to return Exception.

For me the snippet:
...
        if (exchange.getStatus() == ExchangeStatus.ERROR) {
            if (exchange.getError() != null) {
                throw new Exception(exchange.getError());
            } else {
                throw new Exception("Unknown Error");
            }
        } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            try {
                if (exchange.getFault() != null) {
                    SoapFault fault = new SoapFault(SoapFault.RECEIVER,
null, null, null, exchange.getFault().getContent());
                    //sendFault(fault, request, response);
                	sendFault(exchange,fault,request,response);
                } else {
                    NormalizedMessage outMsg = exchange.getMessage("out");
                    if (outMsg != null) {
                        Context context = (Context)
request.getAttribute(Context.class.getName());
                        SoapMessage out = soapHelper.onReply(context,
outMsg);
                        SoapWriter writer = soapMarshaler.createWriter(out);
                        response.setContentType(writer.getContentType());
                        writer.write(response.getOutputStream());
                    }
                }
            } finally {
                exchange.setStatus(ExchangeStatus.DONE);
                channel.send(exchange);
            }
...

in ConsumerProcessor should be replaced with something like:
...
if (endpoing.isSoap())
    new SoapFault();
else
   ...

What you mean?
-- 
View this message in context: http://www.nabble.com/Issue-in-the-way-servicemix-handle-soap-errors-tf1559434.html#a5413095
Sent from the ServiceMix - User forum at Nabble.com.


Re: Issue in the way servicemix handle soap errors

Posted by Eric Dofonsou <ew...@yahoo.com>.
Okay I've looked at a way to implement this.

However I was wondering if I can use XPath to get my
xml attribtues from the soap message to rebuild the
message to be soap 1.1 compliant ?


--- Guillaume Nodet <gn...@gmail.com> wrote:

> I think that the call to
> exchange.setStatus(ExchangeStatus.ERROR) is a bug.
> This is not compliant with the JBI spec (a fault
> should use an ACTIVE status).
> So that should be fixed.
> Next, I think you can not parse the result fault,
> because it is a Soap
> 1.2 fault (soap 1.1 faults are not yet handled), see
>
org.apache.servicemix.soap.marshalers.SoapWriter#writeSoap11Fault(XMLStreamWriter).
> 
> However, I' m not sure what to about the nested soap
> fault ...
> 
> Please, raise a JIRA for this problem.
> And attach a patch for the soap 1.1 fault writer if
> you want ...
> 
> Cheers,
> Guillaume Nodet
> 
> On 5/4/06, Eric Dofonsou <ew...@yahoo.com>
> wrote:
> >
> >
> > Okay here is what I have :
> >
> > Generated Stub -> HTTP Consumer-> HTTP Provider ->
> > JBoss Web Service.
> >
> > So when the generated stubs received the HTTP
> based
> > error message from the servicemix HTTPConsumer
> they
> > cannot parse the message and thus do not handlt eh
> > buisness like they are supposed to be handle.
> >
> > The HTTP Consumer produces this error because it
> > receives a fault message from the HTTP provider
> > endpoint.  I do not think that the Consumer should
> be
> > modified for this.  I think the consumer is doing
> the
> > right think in raising  an HTTP 500 error,
> However, I
> > think that the Provider should have an attribut
> that
> > says do not process error messages (ignoreErrors
> ?).
> > This way the message will be transfered as is to
> the
> > consumer who will return this to the client (a
> stub in
> > my case).  The stub can hand the soap message
> without
> > any problem.
> >
> > Ps:  I've noticed that if I remove the
> > "exchange.setStatus(ExchangeStatus.ERROR);" I get
> the
> > following message from teh server  (which still
> cannot
> > be handle by my stub).  WHat I really want is the
> > soapenv section.
> >
> > ----
> >
> > <env:Envelope
> >
>
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
> >    <env:Body>
> >       <env:Fault>
> >          <env:Code>
> >             <env:Value>env:Receiver</env:Value>
> >          </env:Code>
> >          <env:Details>
> >             <soapenv:Fault
> > xmlns:ns1="http://ws.location.services.com/"
> >
>
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> >               
> <faultcode>soapenv:Server</faultcode>
> >
> >
>
<faultstring>java.lang.IllegalArgumentException</faultstring>
> >             </soapenv:Fault>
> >          </env:Details>
> >       </env:Fault>
> >    </env:Body>
> > </env:Envelope>
> >
> >
> >
> >
> > --- Guillaume Nodet <gn...@gmail.com> wrote:
> >
> > > The error you see is created by a consumer
> endpoint
> > > (not a provider
> > > endpoint) when an error is returned by the
> target
> > > endpoint.
> > > Is this a business exception ? in this case, the
> > > target endpoint
> > > should return a fault, not an error.
> > > Could you please explain the whole flow you use
> ?
> > > I'd like to improve that, but i need a
> reproducible
> > > test / xml configuration ...
> > >
> > > Cheers,
> > > Guillaume Nodet
> > >
> > > On 5/4/06, Eric Dofonsou <ew...@yahoo.com>
> > > wrote:
> > > > Hello,
> > > >
> > > > I am having another issue with the way
> servicemix
> > > > handles all the soap fault message return by
> my
> > > web
> > > > services,
> > > >
> > > > With the current version of servicemix, my
> soap
> > > > message is replace by the following HTTP error
> > > message
> > > > :
> > > > ------
> > > > <html>
> > > >    <head>
> > > >       <title>Error 500 Unknown Error</title>
> > > >    </head>
> > > >    <body>
> > > >       <h2>HTTP ERROR: 500</h2>
> > > >       <pre>Unknown Error</pre>
> > > >       <p>RequestURI=/Service/</p>
> > > >       <p>
> > > >          <i>
> > > >             <small>
> > > >                <a
> > > > href="http://jetty.mortbay.org">Powered by
> > > > Jetty://</a>
> > > >             </small>
> > > >          </i>
> > > >       </p>
> > > >    </body>
> > > > </html>
> > > > ----
> > > >
> > > > because of this message, my generated stubs
> cannot
> > > > properly handle the soap message.
> > > >
> > > > I was wondering if it's not possible to have
> an
> > > > attribut that specifies on a provider endpoint
> > > that we
> > > > do not want servicemix to error message from
> the
> > > web
> > > > service and just return them as is to the
> client.
> > > >
> > > > PS : when I put the block of code that handls
> the
> > > > error message in comment it works fine :
> > > > Here is the black of code from
> ProviderProcessor
> > > that
> > > > is commented out :
> > > > ------------
> > > >             if (response != HttpStatus.SC_OK)
> {
> > > >                 if (exchange instanceof InOnly
> ==
> > > > false) {
> > > >                     Fault fault =
> > > > exchange.createFault();
> > > >                     SoapReader reader =
> > > > soapMarshaler.createReader();
> > > >                     Header contentType =
> > > > method.getResponseHeader("Content-Type");
> > > >                     soapMessage =
> > > > reader.read(method.getResponseBodyAsStream(),
> > > >
> > > > contentType != null ? contentType.getValue() :
> > > null);
> > > >
> > > >
> fault.setProperty(JbiConstants.PROTOCOL_HEADERS,
> > > > getHeaders(method));
> > > >                     jbiMarshaler.toNMS(fault,
> > > > soapMessage);
> > > >                     exchange.setFault(fault);
> > > >
> > > > exchange.setStatus(ExchangeStatus.ERROR);
> > > >                     channel.send(exchange);
> > > >                     return;
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Issue in the way servicemix handle soap errors

Posted by Guillaume Nodet <gn...@gmail.com>.
I think that the call to exchange.setStatus(ExchangeStatus.ERROR) is a bug.
This is not compliant with the JBI spec (a fault should use an ACTIVE status).
So that should be fixed.
Next, I think you can not parse the result fault, because it is a Soap
1.2 fault (soap 1.1 faults are not yet handled), see
org.apache.servicemix.soap.marshalers.SoapWriter#writeSoap11Fault(XMLStreamWriter).

However, I' m not sure what to about the nested soap fault ...

Please, raise a JIRA for this problem.
And attach a patch for the soap 1.1 fault writer if you want ...

Cheers,
Guillaume Nodet

On 5/4/06, Eric Dofonsou <ew...@yahoo.com> wrote:
>
>
> Okay here is what I have :
>
> Generated Stub -> HTTP Consumer-> HTTP Provider ->
> JBoss Web Service.
>
> So when the generated stubs received the HTTP based
> error message from the servicemix HTTPConsumer they
> cannot parse the message and thus do not handlt eh
> buisness like they are supposed to be handle.
>
> The HTTP Consumer produces this error because it
> receives a fault message from the HTTP provider
> endpoint.  I do not think that the Consumer should be
> modified for this.  I think the consumer is doing the
> right think in raising  an HTTP 500 error, However, I
> think that the Provider should have an attribut that
> says do not process error messages (ignoreErrors ?).
> This way the message will be transfered as is to the
> consumer who will return this to the client (a stub in
> my case).  The stub can hand the soap message without
> any problem.
>
> Ps:  I've noticed that if I remove the
> "exchange.setStatus(ExchangeStatus.ERROR);" I get the
> following message from teh server  (which still cannot
> be handle by my stub).  WHat I really want is the
> soapenv section.
>
> ----
>
> <env:Envelope
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
>    <env:Body>
>       <env:Fault>
>          <env:Code>
>             <env:Value>env:Receiver</env:Value>
>          </env:Code>
>          <env:Details>
>             <soapenv:Fault
> xmlns:ns1="http://ws.location.services.com/"
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>                <faultcode>soapenv:Server</faultcode>
>
> <faultstring>java.lang.IllegalArgumentException</faultstring>
>             </soapenv:Fault>
>          </env:Details>
>       </env:Fault>
>    </env:Body>
> </env:Envelope>
>
>
>
>
> --- Guillaume Nodet <gn...@gmail.com> wrote:
>
> > The error you see is created by a consumer endpoint
> > (not a provider
> > endpoint) when an error is returned by the target
> > endpoint.
> > Is this a business exception ? in this case, the
> > target endpoint
> > should return a fault, not an error.
> > Could you please explain the whole flow you use ?
> > I'd like to improve that, but i need a reproducible
> > test / xml configuration ...
> >
> > Cheers,
> > Guillaume Nodet
> >
> > On 5/4/06, Eric Dofonsou <ew...@yahoo.com>
> > wrote:
> > > Hello,
> > >
> > > I am having another issue with the way servicemix
> > > handles all the soap fault message return by my
> > web
> > > services,
> > >
> > > With the current version of servicemix, my soap
> > > message is replace by the following HTTP error
> > message
> > > :
> > > ------
> > > <html>
> > >    <head>
> > >       <title>Error 500 Unknown Error</title>
> > >    </head>
> > >    <body>
> > >       <h2>HTTP ERROR: 500</h2>
> > >       <pre>Unknown Error</pre>
> > >       <p>RequestURI=/Service/</p>
> > >       <p>
> > >          <i>
> > >             <small>
> > >                <a
> > > href="http://jetty.mortbay.org">Powered by
> > > Jetty://</a>
> > >             </small>
> > >          </i>
> > >       </p>
> > >    </body>
> > > </html>
> > > ----
> > >
> > > because of this message, my generated stubs cannot
> > > properly handle the soap message.
> > >
> > > I was wondering if it's not possible to have an
> > > attribut that specifies on a provider endpoint
> > that we
> > > do not want servicemix to error message from the
> > web
> > > service and just return them as is to the client.
> > >
> > > PS : when I put the block of code that handls the
> > > error message in comment it works fine :
> > > Here is the black of code from ProviderProcessor
> > that
> > > is commented out :
> > > ------------
> > >             if (response != HttpStatus.SC_OK) {
> > >                 if (exchange instanceof InOnly ==
> > > false) {
> > >                     Fault fault =
> > > exchange.createFault();
> > >                     SoapReader reader =
> > > soapMarshaler.createReader();
> > >                     Header contentType =
> > > method.getResponseHeader("Content-Type");
> > >                     soapMessage =
> > > reader.read(method.getResponseBodyAsStream(),
> > >
> > > contentType != null ? contentType.getValue() :
> > null);
> > >
> > > fault.setProperty(JbiConstants.PROTOCOL_HEADERS,
> > > getHeaders(method));
> > >                     jbiMarshaler.toNMS(fault,
> > > soapMessage);
> > >                     exchange.setFault(fault);
> > >
> > > exchange.setStatus(ExchangeStatus.ERROR);
> > >                     channel.send(exchange);
> > >                     return;
> > >                 } else {
> > >                     throw new Exception("Invalid
> > > status response: " + response);
> > >                 }
> > >             }
> > > ------------
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > > http://mail.yahoo.com
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Re: Issue in the way servicemix handle soap errors

Posted by Eric Dofonsou <ew...@yahoo.com>.

Okay here is what I have :

Generated Stub -> HTTP Consumer-> HTTP Provider ->
JBoss Web Service.

So when the generated stubs received the HTTP based
error message from the servicemix HTTPConsumer they
cannot parse the message and thus do not handlt eh
buisness like they are supposed to be handle.

The HTTP Consumer produces this error because it
receives a fault message from the HTTP provider
endpoint.  I do not think that the Consumer should be
modified for this.  I think the consumer is doing the
right think in raising  an HTTP 500 error, However, I
think that the Provider should have an attribut that
says do not process error messages (ignoreErrors ?). 
This way the message will be transfered as is to the
consumer who will return this to the client (a stub in
my case).  The stub can hand the soap message without
any problem.

Ps:  I've noticed that if I remove the
"exchange.setStatus(ExchangeStatus.ERROR);" I get the
following message from teh server  (which still cannot
be handle by my stub).  WHat I really want is the
soapenv section.

----

<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Body>
      <env:Fault>
         <env:Code>
            <env:Value>env:Receiver</env:Value>
         </env:Code>
         <env:Details>
            <soapenv:Fault
xmlns:ns1="http://ws.location.services.com/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
               <faultcode>soapenv:Server</faultcode>
              
<faultstring>java.lang.IllegalArgumentException</faultstring>
            </soapenv:Fault>
         </env:Details>
      </env:Fault>
   </env:Body>
</env:Envelope>




--- Guillaume Nodet <gn...@gmail.com> wrote:

> The error you see is created by a consumer endpoint
> (not a provider
> endpoint) when an error is returned by the target
> endpoint.
> Is this a business exception ? in this case, the
> target endpoint
> should return a fault, not an error.
> Could you please explain the whole flow you use ?
> I'd like to improve that, but i need a reproducible
> test / xml configuration ...
> 
> Cheers,
> Guillaume Nodet
> 
> On 5/4/06, Eric Dofonsou <ew...@yahoo.com>
> wrote:
> > Hello,
> >
> > I am having another issue with the way servicemix
> > handles all the soap fault message return by my
> web
> > services,
> >
> > With the current version of servicemix, my soap
> > message is replace by the following HTTP error
> message
> > :
> > ------
> > <html>
> >    <head>
> >       <title>Error 500 Unknown Error</title>
> >    </head>
> >    <body>
> >       <h2>HTTP ERROR: 500</h2>
> >       <pre>Unknown Error</pre>
> >       <p>RequestURI=/Service/</p>
> >       <p>
> >          <i>
> >             <small>
> >                <a
> > href="http://jetty.mortbay.org">Powered by
> > Jetty://</a>
> >             </small>
> >          </i>
> >       </p>
> >    </body>
> > </html>
> > ----
> >
> > because of this message, my generated stubs cannot
> > properly handle the soap message.
> >
> > I was wondering if it's not possible to have an
> > attribut that specifies on a provider endpoint
> that we
> > do not want servicemix to error message from the
> web
> > service and just return them as is to the client.
> >
> > PS : when I put the block of code that handls the
> > error message in comment it works fine :
> > Here is the black of code from ProviderProcessor
> that
> > is commented out :
> > ------------
> >             if (response != HttpStatus.SC_OK) {
> >                 if (exchange instanceof InOnly ==
> > false) {
> >                     Fault fault =
> > exchange.createFault();
> >                     SoapReader reader =
> > soapMarshaler.createReader();
> >                     Header contentType =
> > method.getResponseHeader("Content-Type");
> >                     soapMessage =
> > reader.read(method.getResponseBodyAsStream(),
> >
> > contentType != null ? contentType.getValue() :
> null);
> >
> > fault.setProperty(JbiConstants.PROTOCOL_HEADERS,
> > getHeaders(method));
> >                     jbiMarshaler.toNMS(fault,
> > soapMessage);
> >                     exchange.setFault(fault);
> >
> > exchange.setStatus(ExchangeStatus.ERROR);
> >                     channel.send(exchange);
> >                     return;
> >                 } else {
> >                     throw new Exception("Invalid
> > status response: " + response);
> >                 }
> >             }
> > ------------
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Issue in the way servicemix handle soap errors

Posted by Guillaume Nodet <gn...@gmail.com>.
The error you see is created by a consumer endpoint (not a provider
endpoint) when an error is returned by the target endpoint.
Is this a business exception ? in this case, the target endpoint
should return a fault, not an error.
Could you please explain the whole flow you use ?
I'd like to improve that, but i need a reproducible test / xml configuration ...

Cheers,
Guillaume Nodet

On 5/4/06, Eric Dofonsou <ew...@yahoo.com> wrote:
> Hello,
>
> I am having another issue with the way servicemix
> handles all the soap fault message return by my web
> services,
>
> With the current version of servicemix, my soap
> message is replace by the following HTTP error message
> :
> ------
> <html>
>    <head>
>       <title>Error 500 Unknown Error</title>
>    </head>
>    <body>
>       <h2>HTTP ERROR: 500</h2>
>       <pre>Unknown Error</pre>
>       <p>RequestURI=/Service/</p>
>       <p>
>          <i>
>             <small>
>                <a
> href="http://jetty.mortbay.org">Powered by
> Jetty://</a>
>             </small>
>          </i>
>       </p>
>    </body>
> </html>
> ----
>
> because of this message, my generated stubs cannot
> properly handle the soap message.
>
> I was wondering if it's not possible to have an
> attribut that specifies on a provider endpoint that we
> do not want servicemix to error message from the web
> service and just return them as is to the client.
>
> PS : when I put the block of code that handls the
> error message in comment it works fine :
> Here is the black of code from ProviderProcessor that
> is commented out :
> ------------
>             if (response != HttpStatus.SC_OK) {
>                 if (exchange instanceof InOnly ==
> false) {
>                     Fault fault =
> exchange.createFault();
>                     SoapReader reader =
> soapMarshaler.createReader();
>                     Header contentType =
> method.getResponseHeader("Content-Type");
>                     soapMessage =
> reader.read(method.getResponseBodyAsStream(),
>
> contentType != null ? contentType.getValue() : null);
>
> fault.setProperty(JbiConstants.PROTOCOL_HEADERS,
> getHeaders(method));
>                     jbiMarshaler.toNMS(fault,
> soapMessage);
>                     exchange.setFault(fault);
>
> exchange.setStatus(ExchangeStatus.ERROR);
>                     channel.send(exchange);
>                     return;
>                 } else {
>                     throw new Exception("Invalid
> status response: " + response);
>                 }
>             }
> ------------
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>