Forums Register Login

Returning an array of objects through a web service

+Pie Number of slices to send: Send
Hi
I created a web service which is working correctly, but I can't figure out how to pass objects through it. Here are my object classes:



And here is my web service method to query the database :



When I try to run the method it returns null.
If anyone has any ideas they would be greatly appreciated. Of even a better way then passing them as objects, I am open to ideas.

Thanks.
+Pie Number of slices to send: Send
If the "objects" you want to return are just holders for some strings, why not define your service as returning sets of strings?

Actually the most important questions have to do with the potential clients of this web service. What do you expect clients to be looking for? What software will they be running?

Is this a SOAP or RESTful style service?

Bill
+Pie Number of slices to send: Send
This is a SOAP style service

The objects are just holders of some string, would it be easier to return sets of Strings, I had to set them to objects as it is part of the requirements of my assignment but returning at least a string will be a start.

As for the clients, I would need the client to be able to view the records in the database and scroll through them, then eventually update the database. I have to create two clients using two different software, java (netbeans) and .net (VS 10)


EDIT

I tried to return the Strings I finally got a value apart from null, thanks for that suggestion. Although i'm only receiving the last record in the database, I guess thats why we have to save them in an array of objects to return all the records.
+Pie Number of slices to send: Send
Dominic

I have to ask why you are returning an instance of java.lang.Object to your clients? What do you expect them to do with it, except for a nasty hardcoded cast.

How is your WSDL defined?
+Pie Number of slices to send: Send
I set it to java.lang.Object as I thought since I was returning an object I had to set it to that.

As for the WSDL i have not altered it, I'm testing the web service over local host.
+Pie Number of slices to send: Send
Can you show us your WSDL listing?

Usually a SOAP web service will have its own defined types for a client to consume but these will not normally be java.language.Object.
+Pie Number of slices to send: Send
Hi!
I would recommend creating a Java bean class that contains fields for all the data that is to be returned. Use this return type when declaring the return type of the methods to be exposed in the web service.
This because:
1. Your code will be easier to understand.
2. Such a Java bean will correspond to a XML type, resulting in an element (with contents) in the response XML. If there, in the future, is a need for introducing a new version of the return data, this will be significantly easier with the mentioned construct.
Best wishes!
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2521 times.
Similar Threads
JList Problem
NPE
How to connect Driver
howto Log it? Looking for a generic method that checks objects fields (compare 2 obj)
JDBC and JApplet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 09:38:43.