Android application consuming WCF/RESTful service - android

I have a WCF RESTful application I wrote based off of WcfRestContrib and hosting in iis7.5, which passes a pdf as a byte[]. I'm trying to figure out how, and what the best way would be, to consume this service in an Android application. I believe I took care of all the Java/WCF interop issues because the service is used by an outside company that uses java. But I don't see to many examples out there. I've read that I'm going to have to make a method that passes JSON instead XML, but otherwise I believe it should be usable for an Android app. I'm not seeing too many examples of Android apps that consume RESTful services, is this not the preferred method for Android?
I seen a couple articles (http://romenlaw.blogspot.com/2008/08/consuming-web-services-from-android.html) but most seem kind of old, though they still may be useful. I'm just curious how any experts out there would suggest I handle such a project, I can create another kind of service if need be. I just want to be able to load pdf's from a service based on some parameters. Security is a concern, but not mandatory at this stage. Service currently uses basic auth and is on a https.
Any thoughts? Suggestions?

While also adressing your security concernt, you could use an HttpsURLConnection and then use getInputStream() from that to put it in a bytearray using read().

Related

Android application interacting with a server

Ok so, I know the question is pretty much google-able and I did google it and found out a few answers ,so I am not asking this question knowing completly nothing.
So, I have an application (Cannot specify much about what it does or is or so...) and I need to get some data from a database.
As far as I know, the Volley is the best way to go ,but I am still looking for more details.
Could anyone tell me which is the best way to go?
NOTE: I am NOT looking for code,I am looking for methods.A name would sufice ,as I can do the digging myself.Eventually links to documentations would be awesome, but again, I can find documentations.I just need to know which is the fastest way and the most optimized.
Based on your comment, it looks like there are two different aspects to your application:
Sending out the HTTP requests from your client- i.e. your android app
Processing and sending the response to these requests on the server side, by setting up a web service
Looks like you have part 1 figured out. Note that, volley is a library, similar to android HTTP library, but optimized for faster networking.
For part 2, unless you're planning to use embedded database like sqlite, you'd need to learn about writing web services to provide database access.
Spring Data JPA is one of the many ways to do it.
I hear Parse is great too, but not free.

best practices for restful webservice

Tried to search for this online and didn't get very far, so I'm asking here. What are some of the best practices people have come across for building a website with a restful service? Is it good to combine them both into one or keep them as two separate applications?
Although it depends on a lot of things what's the best to do, what I probably would do is, I'll have a set of "backend" functionality what are doing the "business" things, and the web app will call these functions "directly", and they will be exported as web service calls too. In Java there are lots of handy framework making this very easy - like Spring + Jackson - and I'm sure this is the case in other languages too.

Middleware design for mobile application

I am developing application for iPhone and android. In code i need to access the data from database(oracle) .
I am planning to use REST web services to return JSON data to devices. I dont know much about developing web servies(all i did is 'consumption' part).
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
Now the question came to my mind, i can still manage to return the JSON data from java servlets.
Yes, you can return JSON from java servlets. There are plenty of libraries out there for taking what ever data you've retrieved from you database and serializing it into JSON.
IS there any advantage of using web services. I know for sure I am missing something but want to know what is it.
This is a super general question, but yes. I think the best answer is that (among other things) it gives you an API that arbitrary clients can plug into. So you can expand to new platforms trivial. That's the main benefit as far I see it.

How to use webservices in android?

I want to know about how to call webservices in android I had done a lot of search from Internet and have read several tutorials but was not able to understand much and manipulate, can anyone suggest any Tutorial, or provide any Pdf file or any book related to web services so that I can understand it.
Thanks in advance
The first reading I would suggest is this one - this is the W3School tutorial. Don't forget to read the related chapters included in this tutorial - Soap, Wsdl, etc - as this tutorial taken as a standalone would not be so valuable. This tutorial is not specifically related to Android but will give you all the information needed to understand the use and constraints of this kind of architecture, and then structure your project.
Under Android, you will face the specific contraint of mobile phones and tablets: the network can be down, and is often down: in the tube, in a basement, in any area that have a bad network coverage. So you will have to take care of this, either by caching data or allowing the application to work in degraded mode when no network is available. These are just examples as I don't know your context.
After that, Android is developed in Java, with a specific API that comes on top of the regular java.* packages. These are just tools to implement the client side. On server side, depending of whether you control these services, you may also have some implementation to do. If so, this can be Java, PHP, .Net, anything: one of the purpose of the web services architecture is to stay independant of the remote implementation to only care the exchange protocol. But reading your question, I think the two first points are more important (or have an higher priority let's say) than the implementation as they are prerequisites. (EDIT: Anyway, a useful discussion about that can be found here on StackOverflow.)
Android Doesn't have it's own tool then you should use your own or use some Thing Like KSOAP2.
You Can Use This.
http://www.c-sharpcorner.com/UploadFile/88b6e5/how-to-call-web-service-in-android-using-soap

Android:REST webservice

I have seen the video http://www.youtube.com/watch?v=xHXn3Kg2IQE and it was very interesting.But any one have implemented the REST web service using the services.I am developing the chat app,i need to call the web services in some interval if any one done it then please send me idea about it.
Thank you.
I know you've seen my question about the android restful API service, and think you can do something similar the the answers stated there. You'll need to use a Handler to execute a timed callback from the service.
Also, since that question was answered I've discovered google buffers which may be worth you looking at:
Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.
There are some good examples on the tutorial pages - it'll make your chat client super fast!

Categories

Resources