Hi Sergey,

The XMLBinding was designed with transporting xml over any transport. The
HTTP Binding is focused on ways to build RESTful services over HTTP only. I
wrote some documentation on it here:

http://cwiki.apache.org/confluence/display/CXF20DOC/HTTP+Binding

So you're looking for ways to serve non-xml content - i.e return a JPEG on a
GET request? I would absolutely love this feature. It requires a bit of work
to our databinding code to make this work, and to be honest I haven't
thought about it too much quite yet. Are you interested in helping with this
feature? I will put together some thoughts and help out if so...

FWIW I have written code to serve out static resources on the HTTP Transport
before. Here it is if you're interested:

   private static void serveHTML() throws Exception {
       Bus bus = BusFactoryHelper.newInstance().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.send(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();
               }
           }

       });
   }

- Dan

On 1/25/07, Sergey Beryozkin <[EMAIL PROTECTED]> wrote:

Hi,

Just thinking aloud... So it appears there's no difference between these
bindings, right ?
Would it make sense to differentiate between them like this :

* XMLBinding : used by Provider<Source> providers. Specifically GET
requests are served by returning Source (XMLs).

* HTTPBinding : providers are dealing with request InputStream, response
OutputStream directly.

They implement an interface like handleRequest(InputData, ResponseData),
where InputData/ResponseData encapsulate the underlying engine's details so
that such providers can run on Jetty/Tomcat/etc...

For ex, I need a provider which saves (binary) attachments and then can
serve them through simple GET requests issued from browsers, etc.. I can
implement an XMLBinding (HTTPBinding) provider, but this provider can not
handle GET requests which would just return some non-XML data. Well, it can
return XOP multipart/related packages, but that is not something I need.

Any thoughts ?

Thanks, Sergey


Hi

What is the difference between XML and HTTP bindings from the perspective
of the provider and the client ?
I'm looking at the org.apache.cxf.systest.test , I can see
RestSourcePayloadProvider and RestSourcePayloadProviderHTTPBinding
providers, both are absolutely identical except that the former one has one
extra annotation,
@javax.xml.ws.BindingType(value = http://cxf.apache.org/bindings/xformat)

Corresponding test clients exercising these both providers are absoultely
identical between each other. Are there any subtle differences ?

Thanks, Sergey




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

Reply via email to