Consume ado.net data service from android 2.1 - java

I have a ado.net data service created using VS 2008 sp 1 that is hosted that I want to consume via HTTP and JSON from Android 2.1? Does anyone have sample code on how to do CRUD operations easily do this? I heard Restlet makes this very easy but can't seem to find sample Android code on doing this. If someone can post a tutorial with some actual code that would be greatly appreciated.

here is a good link..
http://composedcrap.blogspot.com/2009/08/connecting-to-net-web-service-from.html
It uses ksoap2 API
http://www.tuxpan.com/android-soap/android-ksoap2-build.zip
another link from right here on SO...
How to call a .NET Webservice from Android using KSOAP2?
And here is a link for Android to WCF....
Can't connect to WCF service on Android
For a RESTful WCF service, here is a good tutorial...
http://mypetprojects.blogspot.com/2009/05/communication-between-wcf-service-and.html

I found another link: http://wiki.restlet.org/docs_2.0/13-restlet/28-restlet/287-restlet/288-restlet.html
Seems usefull.
(+1 for Eclipsed4utoo for all the links!)

Reached here late(or very late) but may help someone in present or future. If you are looking to consume a ado.net data service(now renamed WCF Data Service) from android client, I would recommend you to have a look at the OData4j library. It provides an easy way to access such a service in both xml and json format. Also, it is faster than RESTlet.
Sample code:
ODataConsumer c = ODataJerseyConsumer.create("http://url/WebService.svc");
List<OEntity> listEntities = c.getEntities("Movies").execute().toList();
if (listEntities.size() > 0 ) {
for(OEntity entity : listEntities) {
System.out.println(entity.getProperty("MovieID").getValue().toString());
}
}
You can find more on WCF Data Service and OData4j here.

Related

Android : Step for Android connect to Laravel API

I am new in programming. And I would like to ask what is the step to connect Laravel API. Let say I want to build an Android App and I want to connect to the backend that is Laravel but the point is, the backend is not created by me it is created by other developer and I'm totally don't understand in PHP.
So in this situation, what is the step or how to do Android connect with the Laravel?
PS: I have already saw some sample from other article, but the tutorial mostly are build the both Laravel and Android at the same time. So that is quite not same with my situation...
So Hope I can find out the answer from here. Thanks in advance
You can use Retrofit for creating calling API service in your android application.
This is a very good tutorial: https://www.journaldev.com/13639/retrofit-android-example-tutorial.
For Laravel API, you can follow tutorial: https://www.toptal.com/laravel/restful-laravel-api-tutorial.
The very first step to interacting with a remote REST API is to have an understanding of what the expected request and response data is. This can typically be found in the documentation of the REST API you're trying to access. In this case, since it has been created by another developer, you should ask them for the docs.
After you've gotten a decent understanding of the API, you can use one of several HTTP client libraries for Android such as Retrofit to send requests and receive responses from the API.
Note: It is not necessary to understand the API's code, only the REST endpoints and the request/response schema. A good example of API documentation can be found here

Is it possible to create a client in PHP for Restlet?

Im developing a java application that provides some methods using restlet to a android app.
I created the server and the client using this tutorial
(GAE server and Android client)
Now I need to make a PHP client that is able to access that data. Is that possible? What is the best way to do it?
I already tried to get the data using Advanced REST client but restlet always provide a 404 error
Edit: I can use any web language, PHP was used as an example
I ended up using a restlet extension
I hope it helps somebody else ;)
Restlet provides a way to implement RESTful applications. They are independent from the client so you should be able to consume them with any language.
I would recommend you to enable traces on the server side to find out what happens:
Engine.setLogLevel(Level.FINEST);
You can try to use curl to have a low-level view of exchanged messages (address / path, headers and payload).
Hope it helps you,
Thierry

Implementing custom oauth-provider?

I want to implement Oauth-provider in such a way.
I have one project in which i am accessing the rest apis. Now i want to create my own oauth-provider for every api to hit.I google alot but count not found anything from which i can start my implementation.
I found google code for auth-provider but i am not been able to make it run. Code url is
auth-provider from google code.
In jsp once i say that create my oauth then i want to create oauth setting from my oauth-provider. So that i can get it and send it in header to test my api.
I also download IBM code but not getting how should i start.
IBM oauth 2.0 code
Please help me.
Thanks

Android JSON vs REST

im starting with web services. I'm working in a project that needs to communicate Android with a web server and I'd like to save some time chosing the appropriate protocol for the communication.
Between JSON ,REST and SOAP:
Which ones can I run in a non-dedicated server?
Whats the best choice for a high trafic server?
Thanks in advance
JSON and REST are not mututally exclusive. JSON is a data format that the REST interface can return.
You may run either on a non dedicated server. I would personally choose REST for rapid prototyping on Android as it is easier to get up and running. (With SOAP you will probably want to have a schema which takes time to put together)
There's a good comparison between REST and SOAP on the REST wiki article: http://en.wikipedia.org/wiki/Representational_State_Transfer#Concept
REST is more of a framework than a communications protocol. JSON and SOAP could be use to create a RESTful application.
If you're writing something with many resources, I'd use REST as it is far more structured. There are also a lot of libraries that will set most of things up for you. I find JSON and SOAP are better for custom functionality that you want to hack together quickly. They can be lightweight, but less structured.

Android Client connecting to RestFul Webservice

hello All
I have been fed up of looking for a simple example of rest webservice connecting to Android Application. I know so many people have asked this question before, but there are so many different answers as a theory.
I know I must use restful web-service, rather than SOAP for mobile applications.
I need to create a webservice which is producing JSON, then in Android I can parse the JSON, but the problem is that as I am new to android I am looking for a simple example with both Server and client.
A server : JAVA with Database connection and Restful WebService that produce JSON
Android Client : which parse the JSON result from the webservice
please if somebody can provide such a example , please please help me.
Firstly, before you create your own web service, you might like to experiment with existing web services, such as those provided by Yahoo.
Have a look at the PlaceFinder API by Yahoo, its a free web service you can call, and is quite well documented. You can find the JSON examples here
Create a simple, standard java app that queries that web service, deals with JSON then System.out.print something from the response, that will get you familiar with what you need before you bring the android platform into the question
I haven't used the JSON examples, but I've written a quick tutorial on the XML side which may be of help. Once you're comfortable with this, introduce that code into an Android application and get it to print something on the screen.
You have quite a broad set of requirements in your question, please try what I've recommended then come back with refined further questions
Good luck!

Categories