I am trying to write an Android app to connect to an existing web service. I'm pretty new to web services in general, other than what I've done with this first web services (written with JSPs, Struts 1.x, and JAVA).
This web service is connected to a document storage database. The user would first login to the service, then using search parameters (document title, type, etc.) the user would be displayed a list of possibly relevant documents. The user would choose a specific document f开发者_开发技巧rom that list, and the service would then stream the entire document (pdf file) to the user for viewing.
What methods are available to Android where I can make a request given some specific parameters, and be able to parse a response?
The only thing I know of is HTTP, but my project leader (I'm a summer intern) is hinting that there are others available. I'm not sure where to start looking.
Thank you.
Is it a web service or a web application? If it's a bona fide web service, it should support SOAP or REST, for which there are Java libraries, but none included in Android so far. If it's a web application (just a html based user interface), you're going to have to look at web scraping of some sort -- I hope not, for your sake and for future maintainability. Perhaps you should ask your project leader to be a bit more forthcoming!
You could also find that sending binary messages over socket connections is another option - more opaque and less bytes used. See Google Protocol Buffers for an example.
You should ask for an api document or specification for whatever it is you're going to connect to from the Android app.
For extra credit (I always like to see initiative from Engineering Interns), you may want to volunteer to write the document or to further edit it as necessary.
It is often the case that api docs are out of date or were never really used. (Especially if the same person or team wrote the existing server and client(s).)
I went with using the HttpClient
class. It is working except now I'm struggling with getting my HTTP GET messages short enough. Base64 compression isn't doing quite enough. Thank y'all for your helpful answers.
精彩评论