You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Andrew Clegg <an...@gmail.com> on 2008/09/23 16:39:24 UTC

Manually generating XML for response

Hi folks,

I have a web service that pulls large result sets from a database --
of the order of 10,000-100,000 rows per query, from an 80M row table.

Each record is two short strings and two doubles.

The query itself runs in about 3-5s, and my initial approach has a
data access object which iterates through the result set and produces
a simple Java object for each record on request. My service, which I
haven't finished yet, was going to invoke this DAO and build a list of
the corresponding JAXB objects to be passed back to the client. Nice
clean separation, with the database-specific DAO not depending on the
web service or its databindings.

However, for my test query (returning 85,000 rows) it takes around 10
seconds total to iteratively produce a POJO for each one in the DAO,
and to this I'll need to add a similar amount of time to create the
list of equivalent JAXB objects, plus the additional overhead of
serializing them.

So I'm thinking -- why not 'cheat' and have the database stored
procedure return appropriately formatted XML which can just be
inserted into a response message?

I'm not sure how you would go about doing this in CXF -- would this be
a job for a custom interceptor in the outgoing chain? If anyone can
point me in the direction of an example which would give me a starting
point, I'd be very grateful.

Many thanks!

Andrew.

Re: Manually generating XML for response

Posted by Andrew Clegg <an...@gmail.com>.
Just wanted to say thanks to Glen for pointing me in the direction of
the Provider class, I got it working without too much trouble. I don't
think I'd have found it without help though.

For the good of future searchers, these pages were really useful, once
I knew what I was looking for:

http://cwiki.apache.org/CXF20DOC/provider-services.html
http://i-proving.ca/space/Technologies/Apache+CXF/Provider+Services+and+WS-Security

And it took me a while to figure out that if you're providing just the
payload, you have to qualify it like this:

<myns:MyResponseElement xmlns:myns="http://my.uri.goes.here/"> ...
</myns:MyResponseElement>

... because the automatically-generated envelope won't have a reference to myns.

Cheers,

Andrew.

2008/9/23 Andrew Clegg <an...@gmail.com>:
> Thanks, I've built the cxf sample that uses jax-ws providers, will post
> again if I get stuck.
>
> Andrew.
>
>
> On 23 Sep 2008, at 16:56, Glen Mazza <gl...@gmail.com> wrote:
>
>>
>> I would look at the JAX-WS Provider interface for what you would like to
>> do--that will allow you to work with XML directly.
>>
>> Glen
>>
>>
>> Andrew Clegg wrote:
>>>
>>> Hi folks,
>>>
>>> I have a web service that pulls large result sets from a database --
>>> of the order of 10,000-100,000 rows per query, from an 80M row table.
>>>
>>> Each record is two short strings and two doubles.
>>>
>>> The query itself runs in about 3-5s, and my initial approach has a
>>> data access object which iterates through the result set and produces
>>> a simple Java object for each record on request. My service, which I
>>> haven't finished yet, was going to invoke this DAO and build a list of
>>> the corresponding JAXB objects to be passed back to the client. Nice
>>> clean separation, with the database-specific DAO not depending on the
>>> web service or its databindings.
>>>
>>> However, for my test query (returning 85,000 rows) it takes around 10
>>> seconds total to iteratively produce a POJO for each one in the DAO,
>>> and to this I'll need to add a similar amount of time to create the
>>> list of equivalent JAXB objects, plus the additional overhead of
>>> serializing them.
>>>
>>> So I'm thinking -- why not 'cheat' and have the database stored
>>> procedure return appropriately formatted XML which can just be
>>> inserted into a response message?
>>>
>>> I'm not sure how you would go about doing this in CXF -- would this be
>>> a job for a custom interceptor in the outgoing chain? If anyone can
>>> point me in the direction of an example which would give me a starting
>>> point, I'd be very grateful.
>>>
>>> Many thanks!
>>>
>>> Andrew.
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Manually-generating-XML-for-response-tp19629268p19630883.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>

Re: Manually generating XML for response

Posted by Andrew Clegg <an...@gmail.com>.
Thanks, I've built the cxf sample that uses jax-ws providers, will  
post again if I get stuck.

Andrew.


On 23 Sep 2008, at 16:56, Glen Mazza <gl...@gmail.com> wrote:

>
> I would look at the JAX-WS Provider interface for what you would  
> like to
> do--that will allow you to work with XML directly.
>
> Glen
>
>
> Andrew Clegg wrote:
>>
>> Hi folks,
>>
>> I have a web service that pulls large result sets from a database --
>> of the order of 10,000-100,000 rows per query, from an 80M row table.
>>
>> Each record is two short strings and two doubles.
>>
>> The query itself runs in about 3-5s, and my initial approach has a
>> data access object which iterates through the result set and produces
>> a simple Java object for each record on request. My service, which I
>> haven't finished yet, was going to invoke this DAO and build a list  
>> of
>> the corresponding JAXB objects to be passed back to the client. Nice
>> clean separation, with the database-specific DAO not depending on the
>> web service or its databindings.
>>
>> However, for my test query (returning 85,000 rows) it takes around 10
>> seconds total to iteratively produce a POJO for each one in the DAO,
>> and to this I'll need to add a similar amount of time to create the
>> list of equivalent JAXB objects, plus the additional overhead of
>> serializing them.
>>
>> So I'm thinking -- why not 'cheat' and have the database stored
>> procedure return appropriately formatted XML which can just be
>> inserted into a response message?
>>
>> I'm not sure how you would go about doing this in CXF -- would this  
>> be
>> a job for a custom interceptor in the outgoing chain? If anyone can
>> point me in the direction of an example which would give me a  
>> starting
>> point, I'd be very grateful.
>>
>> Many thanks!
>>
>> Andrew.
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Manually-generating-XML-for-response-tp19629268p19630883.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: Manually generating XML for response

Posted by Glen Mazza <gl...@gmail.com>.
I would look at the JAX-WS Provider interface for what you would like to
do--that will allow you to work with XML directly.

Glen


Andrew Clegg wrote:
> 
> Hi folks,
> 
> I have a web service that pulls large result sets from a database --
> of the order of 10,000-100,000 rows per query, from an 80M row table.
> 
> Each record is two short strings and two doubles.
> 
> The query itself runs in about 3-5s, and my initial approach has a
> data access object which iterates through the result set and produces
> a simple Java object for each record on request. My service, which I
> haven't finished yet, was going to invoke this DAO and build a list of
> the corresponding JAXB objects to be passed back to the client. Nice
> clean separation, with the database-specific DAO not depending on the
> web service or its databindings.
> 
> However, for my test query (returning 85,000 rows) it takes around 10
> seconds total to iteratively produce a POJO for each one in the DAO,
> and to this I'll need to add a similar amount of time to create the
> list of equivalent JAXB objects, plus the additional overhead of
> serializing them.
> 
> So I'm thinking -- why not 'cheat' and have the database stored
> procedure return appropriately formatted XML which can just be
> inserted into a response message?
> 
> I'm not sure how you would go about doing this in CXF -- would this be
> a job for a custom interceptor in the outgoing chain? If anyone can
> point me in the direction of an example which would give me a starting
> point, I'd be very grateful.
> 
> Many thanks!
> 
> Andrew.
> 
> 

-- 
View this message in context: http://www.nabble.com/Manually-generating-XML-for-response-tp19629268p19630883.html
Sent from the cxf-user mailing list archive at Nabble.com.