I am looking for a java based solution for an application with online/offline capabilities. User should be able to work offline (client) and when he comes online on company network, he should be able to send data to the server.
Also need a functionality to send data from server to client. What all APIs can be used?
You may want to develop standalone java application thick client which provides the user a way of saving the work done in local machine then when user choses to go online the saved work can be synchronized over network. This could be done over HTTP or network layer also.
What is the offline work user is going to do? Is it something like outlook mail client ?
I think it's advisable to separate the two parts - saving offline to work for later synchronization, and actually sending it to the server later.
Saving could take any number of forms, depending on the data (or Java objects) you need to store. One of the easiest is probably to use serialization, either of the javax.xml.XMLEncoder shape if the objects are JavaBeans, or of the binary variety (using ObjectOutputStream) if they are not. You could also use a flat file if the data items are simple.
As to sending the data to the server, all kinds of routes are possible: email, JMS, HTTP, sockets, web services... It depends on what the server supports, and makes sense for the data in question. Email and JMS send unformatted data, so the server would need to interpret/parse it in some fashion. HTTP allows to send name/value pairs, which is a step up. Web services have a notion of data types, so that's at an even higher level. Without knowing anything about the application in question, I'd probably go with an HTTP or web service solution.
One issue you need to think about is synchronization. After the user's last server access the data on the server may have changed, which could impact whether the changes the user is about to upload are still valid, or whether they should be rejected. It's possible that your application doesn't need to worry about that, though.
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, that will fit in a stocking