On Fri, Jul 16, 2010 at 5:26 AM, Daniel Kulp <[email protected]> wrote:

> On Friday 09 July 2010 4:14:18 am Rice Yeh wrote:
> > Hi,
> >   Could local transport be used in JAX-RS server? All the examples I can
> > find is for JAX-WS.
>
> Honestly, I don't really know.  I cannot think of any reason why NOT, but
> there might be a property or something mapped a bit differently that would
> need to be taken into account.   There might be some stuff in the JAX-RS
> that
> requires the information from the HttpServletRequest/Response object that
> obviously would not be available.
>

I am trying it. But I am stuck in line 315 of
org.apache.cxf.jaxrs.client.AbstractClient where a HttpURLConnection is
expected. I am using WebClient to send my request. With WebClient, a lot of
code seesm closely coupled to http like line 621 in WebClient where
HTTPConduit.KEY_HTTP_CONNECTION is assumed.

 My code is like below:

        Bus bus = BusFactory.getDefaultBus();

        LocalTransportFactory localTransport = new LocalTransportFactory();

        DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http";,
localTransport);
        dfm.registerDestinationFactory("
http://schemas.xmlsoap.org/wsdl/soap/http";, localTransport);
        dfm.registerDestinationFactory("
http://cxf.apache.org/bindings/xformat";, localTransport);
        dfm.registerDestinationFactory("
http://cxf.apache.org/transports/local";, localTransport);

        ConduitInitiatorManager extension =
bus.getExtension(ConduitInitiatorManager.class);
        extension.registerConduitInitiator("
http://cxf.apache.org/transports/local";, localTransport);
        extension.registerConduitInitiator("
http://schemas.xmlsoap.org/wsdl/soap/http";, localTransport);
        extension.registerConduitInitiator("
http://schemas.xmlsoap.org/soap/http";, localTransport);
        extension.registerConduitInitiator("
http://cxf.apache.org/bindings/xformat";, localTransport);

        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setServiceBeans(new PassThroughResource());
        sf.setAddress("local://passthru");
        sf.create();

        WebClient client = WebClient.create("local://passthru");

        String css =
client.path("css/commons.css").accept("*/*").get(String.class);
        System.out.println(css);



>
> That all said, if someone tried it and created some test cases, we could
> fix
> any bugs that pop up.   :-)
>
> Dan
>
>
> >
> > Regards,
> > Rice
>
> --
> Daniel Kulp
> [email protected]
> http://dankulp.com/blog
>

Reply via email to