I have not tested this myself, but I was wondering whether an
ExceptionMapper<NotFoundException> might work?

Something like:

@Provider
public class ForwardIfNotFoundExceptionMapper implements
ExceptionMapper<NotFoundException> {

    @Context
    UriInfo uriInfo;

    @Context
    Request request;

    @Override
    Response toResponse(NotFoundException ex) {
        Client c = ClientBuilder.newClient();
        return
c.target(uriInfo.getRequestUri()).request().method(request.getMethod())
    }
}

You might also need to "copy" the headers from the request into the client
request.

Hope this helps,

Andy

On Tue, Jan 28, 2020 at 6:51 AM RobCodes <[email protected]> wrote:

> Hi Rice,
>
> I recently figured out how to extend for a custom class as well. I think
> you
> will find this useful though I can't speak to actually forwarding the
> request. I chose the annotation approach but there are other ways to do it.
> Please see:
>
> https://cxf.apache.org/docs/interceptors.html
> and
> https://cxf.apache.org/docs/configuration.html
>
> Excerpts from the first page referenced above:
> ----------------------
> You can also use annotation to add the interceptors from the SEI or service
> class. When CXF create the server or client, CXF will add the interceptor
> according with the annotation.
>
> @org.apache.cxf.interceptor.InInterceptors (interceptors =
> {"com.example.Test1Interceptor" })
> @org.apache.cxf.interceptor.InFaultInterceptors (interceptors =
> {"com.example.Test2Interceptor" })
> @org.apache.cxf.interceptor.OutInterceptors (interceptors =
> {"com.example.Test1Interceptor" })
> @org.apache.cxf.interceptor.InFaultInterceptors (interceptors =
> {"com.example.Test2Interceptor","com.example.Test3Intercetpor" })
> @WebService(endpointInterface =
> "org.apache.cxf.javascript.fortest.SimpleDocLitBare",
>             targetNamespace = "uri:org.apache.cxf.javascript.fortest")
> public class SayHiImplementation implements SayHi {
>    public long sayHi(long arg) {
>        return arg;
>    }
>    ...
> }
>
> ----------------
>
> Adding MyInterceptor to the bus:
>
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:cxf="http://cxf.apache.org/core";
>        xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd";>
>
>     <bean id="MyInterceptor" class="demo.interceptor.MyInterceptor"/>
>
>
>
>     <cxf:bus>
>         <cxf:inInterceptors>
>             <ref bean="MyInterceptor"/>
>         </cxf:inInterceptors>
>         <cxf:outInterceptors>
>             <ref bean="MyInterceptor"/>
>        </cxf:outInterceptors>
>     </cxf:bus>
> </beans>
> ---------------------
>
> Hope this helps while waiting a response from the CXF team.
>
>
>
> -----
> Regards,
> RobCodes
> --
> Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html
>

Reply via email to