Java Web Services

TeRRoRByteZ2007

Well-Known Member
Joined
Jan 10, 2008
Messages
339
Reaction score
0
Location
East London
Hi there all, can anyone help me please.

I'm busy with a project, creating an Auction web site. I'm using JSP's and Web Services. What I want to know is, is it possible for a Web Service to return a ResultSet to a JSP? (After it made the query) If it is, does anyone maybe have an example, a very simple one just so that I can understand how to do it.

Ok so in short, the Web Service is located on the server, client makes use of the web service when wanting to view the products, the web service queries the database for products and returns the ResultSet.

I'm using NetBeans and Sun Java System Application Server. I must use these for the project.

I have tried returning an ArrayList from the web service, but get an error "collection cannot be used in literal mode" when deploying the project.

When I use ResultSet as I would want to iterate through it on the JSP I get a error on the JSP, "found : java.sql.ResultSet required : auctionservice.ResultSet". If I cast it to java.sql.ResultSet, there is nothing in the ResultSet, and if I use auctionservice.ResultSet, there are no methods.

I've been sitting a few days now trying to figure this out and guess it is time now to ask :D Any help and recommendations would really be appreciated! :p
 
Well, speaking purely from an ASP.NET / C# background in web services, it should be possible. Seems to me like there's an object serialization issue in your problem. Remember, the data (objects) returned from your web service need to be serialized and transferred via SOAP to the application invoking the service.
 
Well, speaking purely from an ASP.NET / C# background in web services, it should be possible. Seems to me like there's an object serialization issue in your problem. Remember, the data (objects) returned from your web service need to be serialized and transferred via SOAP to the application invoking the service.

Thanks for the reply, will try this again. Did try it before but got an error, this it was "Incorrect format for JAX-RPC". But will try it out now and give the exact error.

Ok the exact error is "Invalid type for JAX-RPC structure"
 
Last edited:
Can't you just return XML instead?

I was thinking of that, but just thought it would be easier to return the ResultSet or my own class that implements Serializable. But guess I'll probably have to create a XML on the web service and return that to the JSP and then use a XML parser.
 
if you have a webservice, you can return anything

function


blablabla

return "XYZ"

end function


Not sure in JSP, but you'd then do something along the likes of


something = my.webservicefunction

That will then load whatever the webservice returns to you in your own variable.

FYI, webservices returns XML
 
Ok I finally got my objects to Serialize properly, the problem was that didn't add setter methods only had getter methods. So thats finally working now. But now I'm still stuck because, I can only create one instance of the products class that I created, but I need to return all the products to the jsp page. For some reason I thought it would be possible, but because its a Friday my brain just wont work :D Remember I cant use ArrayLists... or maybe I'm just doing it wrong.
 
Oh yes, that's a problem that drove me mad the first time I had to serialize objects via Web Services! You cannot serialize read only properties...
 
Your Resultset will be rendered in SOAP compliant XML. You still need to parse and retrieve values.
Very bad design tho. De-couple your front end from the backend.
Introduce a transfer object of sorts.
 
Top
Sign up to the MyBroadband newsletter
X