BTW, you may also be interested in this code that I wrote to serve out
static HTML files once upon a time:

   private static void serveHTML() throws Exception {
       Bus bus = BusFactory.getDefaultBus();
       DestinationFactoryManager dfm = bus.getExtension(
DestinationFactoryManager.class);
       DestinationFactory df = dfm.getDestinationFactory("
http://cxf.apache.org/transports/http/configuration";);

       EndpointInfo ei = new EndpointInfo();
       ei.setAddress("http://localhost:8080/test.html";);

       Destination d = df.getDestination(ei);
       d.setMessageObserver(new MessageObserver() {

           public void onMessage(Message message) {
               try {
                   // HTTP seems to need this right now...
                   ExchangeImpl ex = new ExchangeImpl();
                   ex.setInMessage(message);

                   Conduit backChannel = message.getDestination().
                       getBackChannel(message, null, null);

                   MessageImpl res = new MessageImpl();
                   res.put(Message.CONTENT_TYPE, "text/html");
                   backChannel.prepare(res);

                   OutputStream out = res.getContent(OutputStream.class);
                   FileInputStream is = new FileInputStream("test.html");
                   IOUtils.copy(is, out, 2048);

                   out.flush();

                   out.close();
                   is.close();

                   backChannel.close(res);
               } catch (Exception e) {
                   e.printStackTrace();
               }
           }

       });
   }

Ugly, but it works ;)

- Dan

On 7/14/07, Dan Diephouse <[EMAIL PROTECTED]> wrote:

Hi Benson,

You're very close to getting it to work :-)  If you look at the
cxf-extension-http-jetty.xml file you'll see that we associate several
transport IDs with that transport:

    <bean class="
org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory"
lazy-init="true">
        <property name="bus" ref="cxf"/>
        <property name="transportIds">
            <list>
                <value>http://schemas.xmlsoap.org/soap/http</value>
                <value> http://schemas.xmlsoap.org/wsdl/http/</value>
                <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
                 <value> http://www.w3.org/2003/05/soap/bindings/HTTP/
</value>
                <value>http://cxf.apache.org/transports/http/configuration
</value>
                <value>http://cxf.apache.org/bindings/xformat</value>
            </list>
        </property>
    </bean>

In code form, this is equivalent to:

Set<String> tids = new HashSet<String>();
tids.add("http://schemas.xmlsoap.org/soap/http";);
... etc for all transport ids

httpTransport.setTransportIds(tids);

for (String tid : tids) {
  dfm.registerDestinationFactory(tid, httpTransport);
}

We should really write some docs on the transport layer, but hopefully
this will get you going in the meantime.

Thanks,
- Dan


On 7/13/07, Benson Margulies <[EMAIL PROTECTED]> wrote:
>
> I set out to replace JettyHTTPTransportFactory with a slightly modified
> version. So, I wrote the code below.
>
> The effect is an NPE when my factory object is asked for its
> transportIds, of which it has none. When I don't try to set this up, the
>
> default transport factory does not get asked for its transport ids,
> apparently because other things that aren't initialized protect it from
> being asked.
>
> I think I see what the transport Id has to be for SOAP, so I can just
> set it, but is this idea supposed to work without that?
>
>
>
>        Bus bus =  BusFactory.getDefaultBus();
>         DestinationFactoryManager dfm =
> bus.getExtension(DestinationFactoryManager.class);
>         JettyHTTPTransportFactoryForStaticContent transportFactory = new
> JettyHTTPTransportFactoryForStaticContent();
>         transportFactory.setBus(bus);
>
> dfm.registerDestinationFactory("http://cxf.apache.org/transports/http/co
> nfiguration", transportFactory);
>



--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog




--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Reply via email to