I am using Apache CXF (apache-cxf-2.5.0) to create Web Services using bottum up approach (Java first approach). I want to return some data / records (for example username, email) from a database table using web services created by bottum up approach (Java first approach). I can write Java class which returns single response. But I am not able to find way to return a response such as data / records (for example username, email) from a database table. How to do that?
1. If I want to send data as a String data, how to send that from the function (say sendData()) in my Java class as examples on the internet have shown sending only one String as a response?
Yes, you can send it (String can have values with some delimiter)
2. Is it possible/OK to send/return POJO as a response?
Yes, you can send POJO.
3. If I want to send data as POJO, how client which is a Android application can know which type of data is this and retrieve data from POJO?
You can use XML to send the data
I don't know the size of your service or the system it exists in, but here are some general advise:
- Consider using some method of describing the input and output to/from the service.
The way of describing the data going in and out of the service of course depend on what kind of data it is.
If the service accepts XML, then use an XML schema. For JSON there are some attempts at JSON schema.
Alternatively, a written document of some kind will also suffice.
- When designing the format of the data going in and out of the service, consider what will happen if you need to extend, or in some other way modify, the data.
Perhaps you want to be able to have different versions of one kind of request etc etc.
- Write your code with request and response handling modular and extensible.
I am creating Apache CXF (apache-cxf-2.5.0) SOAP based Web Services. It creates WSDL from Java class (Java first approach). I have to use SOAP and can't use REST.
I am retrieving data from database using ResultSet. Data is about 5 columns and over 100 rows. Now I want to send this data to Android client. I am thinking of converting ResultSet into ArrayList and sending ArrayList / List object as a response from SOAP Web Service. My problem is - is it possible to send List object as a reponse from SOAP Web Service. If yes, please provide me link to such an examples.