In case anybody comes across this, I think it's a bug, because I can't see
why anybody would want a different exception thrown from local:// then
http://, but I found an easy work around in any case. Create the 2 classes
below and then use the new ClientProxyFactoryBeanSubstitute class below
instead of the ClientProxyFactoryBean to create your service.

package com.mypackage;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;

public class ClientProxyFactoryBeanSubstitute extends
org.apache.cxf.frontend.ClientProxyFactoryBean {
        protected ClientProxy clientClientProxy(Client c) {
                return new ClientProxySubstitute(c);
        }
}

package com.mypackage;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.interceptor.Fault;

public class ClientProxySubstitute extends
org.apache.cxf.frontend.ClientProxy {
        public ClientProxySubstitute(Client c) {
                super(c);
        }
        public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
                try {
                        return super.invoke(proxy, method, args);
                }
                catch (Fault ex) {
                        if (ex.getCause() != null)
                                throw ex.getCause();
                        else
                                throw ex;
                }
        }

}


Dan Dubinsky wrote:
> 
> Hi All,
> 
> I think I may have come across a bug in CXF-2.2.7.    Let's say I have a
> service method that looks like this:
> 
>    public void someMethod() throws ServiceException
> 
> I'm using the Aegis databinding.
> 
> If I use the local:// protocol to invoke it and the method throws a
> ServiceException, the client proxy method is throwing
> org.apache.cxf.interceptor.Fault with ServiceException as the cause.
> 
> If I use http:// protocol to invoke it and the method throws a
> ServiceException, the client proxy is throwing my ServiceException.
> 
> In CXF 2.1 either protocol threw my Exception and not the CXF fault, but
> not 2.2.7. It's kind of a big deal because I have a lot of code already
> written in my system and I would have to go through it all and change the
> exception handling. 
> 
> Anybody have any suggestions?
> 
> Thanks,
> Dan
> 
> PS: Here is how I'm creating the service on the client side:
> 
> ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
> factory.getClientFactoryBean().getFeatures().add(new ColocFeature());
> factory.setServiceClass(serviceInterface);
> factory.setAddress(serviceURL);
> factory.setDataBinding(new AegisDatabinding());
> service = factory.create()
> 
> 
>                                       
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Wrong-Exception-Thrown-using-local%3A---service-tp28382624p28387978.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to