You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by sushi mitra <su...@hotmail.com> on 2001/06/27 00:49:21 UTC

simple-jdbc web services question

Hi,

I wrote a simple web service which is returning result of a sql query. I am 
wondering how do I return the ResultSet to the client. I understand I need 
to write a bean, but not sure how I am going to do it.

Thanks
SM
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Re: simple-jdbc web services question

Posted by "Javier A. Soltero" <ja...@covalent.net>.
Or, if you'd rather write a bean, then all you need to do is write a class which
represents the items in your result set. The only thing that qualifies it as a
bean suitable for SOAP tranfer is the following easy rules:

- constructor with no arguments
- for an attribute: String anAttribute
there should be a:
public String getAnAttribute() { <-- note capitalization
and a:
public void setAnAttribute(String foo) { <-- capitalization here also

... do this for all the attributes, return them either in an array or a vector,
and make sure your deployment descriptor includes information which tells soap
to use the BeanSerializer to serialize the bean type you're expecting to return
through soap. Also you need to do the equivalent on the client side to make sure
you can translate the xml back to a bean on that end. Look at the 'defining type
mappings' section of the docs to see exactly how this works.

Hope this helps...
-javier

Oleg Dulin wrote:

> On Tue, 26 Jun 2001, sushi mitra wrote:
>
> > Hi,
> >
> > I wrote a simple web service which is returning result of a sql query. I am
> > wondering how do I return the ResultSet to the client. I understand I need
> > to write a bean, but not sure how I am going to do it.
>
> Come up with an XML representation of the result set and write a class
> that traverses the ResultSet and builds an org.w3c.dom.Element object and
> returns it as a result. AFAIK, Apache SOAP can accept an Element as a
> parameter.
>
> Oleg


Re: simple-jdbc web services question

Posted by "Javier A. Soltero" <ja...@covalent.net>.
Or, if you'd rather write a bean, then all you need to do is write a class which
represents the items in your result set. The only thing that qualifies it as a
bean suitable for SOAP tranfer is the following easy rules:

- constructor with no arguments
- for an attribute: String anAttribute
there should be a:
public String getAnAttribute() { <-- note capitalization
and a:
public void setAnAttribute(String foo) { <-- capitalization here also

... do this for all the attributes, return them either in an array or a vector,
and make sure your deployment descriptor includes information which tells soap
to use the BeanSerializer to serialize the bean type you're expecting to return
through soap. Also you need to do the equivalent on the client side to make sure
you can translate the xml back to a bean on that end. Look at the 'defining type
mappings' section of the docs to see exactly how this works.

Hope this helps...
-javier

Oleg Dulin wrote:

> On Tue, 26 Jun 2001, sushi mitra wrote:
>
> > Hi,
> >
> > I wrote a simple web service which is returning result of a sql query. I am
> > wondering how do I return the ResultSet to the client. I understand I need
> > to write a bean, but not sure how I am going to do it.
>
> Come up with an XML representation of the result set and write a class
> that traverses the ResultSet and builds an org.w3c.dom.Element object and
> returns it as a result. AFAIK, Apache SOAP can accept an Element as a
> parameter.
>
> Oleg


Re: simple-jdbc web services question

Posted by Oleg Dulin <du...@acm.org>.
On Tue, 26 Jun 2001, sushi mitra wrote:

> Hi,
>
> I wrote a simple web service which is returning result of a sql query. I am
> wondering how do I return the ResultSet to the client. I understand I need
> to write a bean, but not sure how I am going to do it.

Come up with an XML representation of the result set and write a class
that traverses the ResultSet and builds an org.w3c.dom.Element object and
returns it as a result. AFAIK, Apache SOAP can accept an Element as a
parameter.



Oleg


Re: simple-jdbc web services question

Posted by Oleg Dulin <du...@acm.org>.
On Tue, 26 Jun 2001, sushi mitra wrote:

> Hi,
>
> I wrote a simple web service which is returning result of a sql query. I am
> wondering how do I return the ResultSet to the client. I understand I need
> to write a bean, but not sure how I am going to do it.

Come up with an XML representation of the result set and write a class
that traverses the ResultSet and builds an org.w3c.dom.Element object and
returns it as a result. AFAIK, Apache SOAP can accept an Element as a
parameter.



Oleg