You could write a new frontend to the wsdl2java stuff to handle #2 if you 
wanted.    Basicially, you could subclass the SEIGenerator and override the 
    protected void doWrite(String templateName, Writer outputs) throws 
ToolException {

method to change the templateName to a new template name where you can 
customtomize whatever you want.    You would need a jar with your subclass 
in it, your template in it, and a META-INF/tools-plugin.xml that would look 
something like:

<plugin name="mygen" version="" 
provider="cxf.apache.org" xmlns="http://cxf.apache.org/tools/plugin";>
    <frontend name="mygen"          
package="org.apache.cxf.tools.wsdlto.frontend.jaxws" 
profile="JAXWSProfile">
           <container name="JAXWSContainer" toolspec="jaxws-toolspec.xml"/>
           <processor name="WSDLToJavaProcessor" 
package="org.apache.cxf.tools.wsdlto.frontend.jaxws.processor"/>
           <builder name="JAXWSDefinitionBuilder" 
package="org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11"/>
           <generators 
package="org.apache.cxf.tools.wsdlto.frontend.jaxws.generators">
               <generator name="AntGenerator"/>
               <generator name="ClientGenerator"/>
               <generator name="FaultGenerator"/>
               <generator name="ImplGenerator"/>
               <generator name="SEIGenerator" package="my.package"/>
               <generator name="ServerGenerator"/>
               <generator name="ServiceGenerator"/>
           </generators>
    </frontend>
</plugin>

or similar where the SEIGenerator is your subclass.

Dan




On Tuesday, July 03, 2012 02:34:34 AM nicola.tu wrote:
> Hi all,
> 
> I'm reopening this thread because in the meanwhile there may have been
> some updates that I've missed.
> 
> The original problem (and for me still open) is that if the called service
> returns a SOAPFaultException (or a javax.xml.ws.WebServiceException), the
> client needs explicitely to add the catch() clause.
> In axis, any ws call was throwing a RemoteException, so my client was
> obliged to catch it. In CXF these are all RuntimeException, so I need to
> remember to catch them and send back to the caller some graceful error
> message.
> 
> try {
>       ServiceDataInfoResponse resp = client.getServiceDataInfo(req);
>       return resp;
> } catch (javax.xml.ws.WebServiceException e) {
>       // I need to remember to add this catch all the times!!
>       throw new MyBusinessException("We are sorry, the service is currently 
not
> available.");
> }
> 
> I see 2 possible solutions, but none fully satisfying:
> 1. Add a custom SoapInterceptor to the list of client's
> InFaultInterceptors() and implement my handleFault(). Here I still don't
> know how to notify the fault in a graceful way to the caller.
> 2. Manipulate the @WebService interface and let the methods throw a
> non-runtime exception (like java.rmi.RemoteException in axis), which I'm
> obliged to catch.
> 
> Has anyonw already faced this issue?
> 
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Handling-internal-errors-via-SOAP-faults-
> tp559600p5710576.html Sent from the cxf-user mailing list archive at
> Nabble.com.
-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to