cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sergey.beryoz...@iona.com>
Subject Re: Difference between XML and HTTP bindings
Date Thu, 25 Jan 2007 17:34:20 GMT
Hi Dan

Ok, thanks for the explanation and for the code sample.

I've just discovered that by implementing Provider<DataSource> (ServiceMode = Message)
I can retrieve binary/XML data as is using GET, it was a nice surprize, but a bit unusual
:-)... 

On the example itself :

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

Would this work if I do it like this (with a stem mode) :

>        ei.setAddress(http://localhost:8080/data);

and then in 

>            public void onMessage(Message message) {

server requests like 

http://localhost:8080/data/my.jpeg
http://localhost:8080/data/my.bmp ?

> 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...

Lets get the conversation started :-). Would it be HTTPBinding which would have to updated
slightly to help providers willing to just get input and output streams and deal with them,
and such that they don't see the details like the ones shown in your example ? Or will it
be done similar to your example below, without bindings involved ? What kind of interface
such providers will implement ?


Thanks, Sergey




> 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 <sergey.beryozkin@iona.com> 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
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message