This is definitely a bug.    I just traced through it and the 
HandlerChainInvoker doesn't convert the SOAPFaultException to our 
internal SoapFault.   Thus, the rest of the runtime just thinks it's a 
generic exception thing.   

Most likely, in the catch (ProtocolException) thing in 
HandlerChainInvoker, what we need to do is convert it before rethrowing 
it if on the server (not on the client or we'd just have to convert it 
back) if it's a SOAPFaultException.    The code to do the convert is in 
the JAXWSMethodInvoker.    Just need to copy it.  

Can you log a bug in jira with all this so it's tracked?   
https://issues.apache.org/jira/browse/CXF
I may be able to get to it later this week.   That said, feel free to 
copy the code from the method invoker, test it, and send a patch if it 
works.   :-)

Dan


On Monday 04 February 2008, Davide Gesino wrote:
> I am trying to throw a SOAPFaultException from an handler. Anyway I
> have some weird error in what I get back.
> I have tried the same code on java 6 without CXF and the handler chain
> works differently (with java 1.6 works fine)
>
> This is the handleMessage on my custom SOAPHandler (the way I fill the
> SOAPFault is taken from the SUN tutorial):
>
> 1) WITH JAVA 6:
>
> public boolean handleMessage(SOAPMessageContext ctx) {
>               Boolean outboundProperty = (Boolean) ctx
>                               .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
>
>               if (!outboundProperty) {
>                       SOAPMessage msg = ctx.getMessage();
>                       SOAPBody body;
>                       try {
>                               body = msg.getSOAPBody();
>
>                               SOAPFault fault = body.addFault();
>                               QName faultName = new 
> QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,
>                                               "Server");
>                               fault.setFaultCode(faultName);
>                               fault.setFaultActor("http://gizmos.com/orders";);
>                               fault.setFaultString("Server not responding");
>
>                               Detail detail = fault.addDetail();
>
>                               QName entryName = new 
> QName("http://gizmos.com/orders/";,
>                                               "order", "PO");
>                               DetailEntry entry = 
> detail.addDetailEntry(entryName);
>                               entry.addTextNode("Quantity element does not 
> have a value");
>
>                               QName entryName2 = new 
> QName("http://gizmos.com/orders/";,
>                                               "order", "PO");
>                               DetailEntry entry2 = 
> detail.addDetailEntry(entryName2);
>                               entry2.addTextNode("Incomplete address: no zip 
> code");
>
>                               throw new SOAPFaultException(fault);
>
>                       } catch (SOAPException e) {
>                               // TODO Auto-generated catch block
>                               e.printStackTrace();
>                       }
>               }
>
>               return true;
>       }
>
>
> and here is the log of the message sent back to the client. The
> SOAPFault is populated correctly.
>
> <soapenv:Fault>
>       <faultcode>soapenv:Server</faultcode>
>       <faultstring>Server not responding</faultstring>
>       <faultactor>http://gizmos.com/orders</faultactor>
>       <detail>
>         <PO:order xmlns:PO="http://gizmos.com/orders/";>Quantity
> element does not have a value</PO:order>
>         <PO:order xmlns:PO="http://gizmos.com/orders/";>Incomplete
> address: no zip code</PO:order>
>       </detail>
>   </soapenv:Fault>
>
>  2) WITH CXF + Java 5:
>
> I have the same handler doing the same work. debugging the SOAPFault
> seems to be populated correctly:
> Anyway logging the answer here is what I get.
>
>
>  <soap:Fault>
>       <faultcode>soap:Server</faultcode>
>       <faultstring>Server not responding</faultstring>
> </soap:Fault>
>
> The actor and expecially the details are missing.
> I have tried debugging the
> org.apache.cxf.jaxws.handler.HandlerChainInvoker, but I was not abel
> to figure out if there is some error somewhere. Do you think it is a
> bug or an hidden error of mine?
>
> Thanks a lot.
>
> Davide



-- 
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog

Reply via email to