I'm new in Android and I have to do an application (in android) that consumes a NET WCF service with httpbasicbinding. I have heard about use of ksoap2-android, json and restfull but I don't know which is the best way for my app.
Anyone can suggest me anything?
Another problem is my WCF service return complex objects made by Linq To Sql and I don't know how can I use it in Android.
Thanks in advance!
If you use oData web services you can use the odata4j client library.
If you're using Service Stack to develop your web services you can use any REST client to easily consume them (in any format i.e. JSON, XML, JSV, SOAP, etc). The Hello World example shows a number of different ways you can consume a single web service.
Related
I'm new to android, I'm trying to build an android app that is a front for a web portal. For example, Airbnb. They have a website, but they also have an android app that, using it's own layout, will show listings from their website.
There are many websites that teach how to or even directly convert your website to android apps. However, this will result in an app that loads too slowly and is unresponsive due to CPU usage.
Could anyone share any tutorial/guide to learn how to do this myself?
Million thanks.
To actually load data from a web server you're gonna need and API which usually delivers the proper date using JSON or XML format so that you can properly parse and display that data. Building this API is in it self a complete course on its own.
But connecting to and requesting data from the API is usually done using some networking libraries. These are some of the better know libraries for this purpose.
OkHttp: A complete library with a set of tools for handling network connections and HTTP requests.
RetroFit:Type-safe HTTP client for Android and Java by Square, Inc. which is built on top of OkHttp.
Async-Http-Client:
The Async Http Client library's purpose is to allow Java applications
to easily execute HTTP requests and asynchronously process the HTTP
responses. The library also supports the WebSocket Protocol. The Async
HTTP Client library is simple to use.
There tons of other good libraries.
its called webservices
Through android you get data in form of json from a web server and then return in custom view as you want.
Follow this link hope it will help
Step by Step Method to Access Webservice from Android
you would have to write an API/Web service or use if already exits to fetch data from web server. Basically the concept is that, the website itself must be pulling data from some database, so write an API which would fetch the data from same API and return JSON data and consume the API from your android app.
If you know PHP refere to this for the help :http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
You can write WebService, in programming it generally refers to a web page(ex. Airbnb), that can be called from your android application which can pass in data to it, or receive data from it.
WebService is basically like a 'method' or 'function' in a normal programming language; except you're calling it over the internet.
The first thing is you have to create a Web Service. The Web Service will be your "bridge" to consume the data from other Website like airbnb or others and return the data to your android through json format for example.
You can create a Web Service using many languages like C#, Java, PHP, etc. I would like to recommend you to use the language that you know the most.
You can try to google this
Cheers
I am trying to build an Android application.
It has a SOAP-based Web service from which it needs to consume the data.
I have a middle-ware Worklight server implementation too.
The data coming from the Web Service is huge and is actually all the data is not needed all the time. I was planning that I would use the middleware Worklight server to consume the SOAP web service, rather than the Android app itself, parse the data and then expose the required bits as a RESTful service and the data format JSON rather than SOAP XML format.
I think that this will take the load of parsing the huge XML data off the app. Is this a good approach?
I see no problem with your overall design, i.e. consuming the large chunk of data from the SOAP call in your middleware server and then only exposing the specific things you need for your Android clients.
It will at least save you bandwidth on your Android devices (which is a really good thing) and most likely a few lines of code in your Android project since your REST data will be tailored for your specific use-cases.
JSON or XML? What better fits your needs.
I'd advice you to look at versioning your REST services though. This is a good start: Best practices for API versioning?
I've been reading some info about Web Services for Android using SOAP or REST but I've never created a web service so I have many questions about this.
I'm developing an Android App where the users answer some questions and for each user an XML file is generated and saved in the device.
Here are my queries:
What I would like to do is to send these XML files from the devices to the Web Service and also sometimes to retrieve all the files to any
device.
Do I need to convert these files into Byte or just send the XML?
Are these actions possible with the Web Service or will you use Java Sockets? In case you prefer the Web Service, what would you use:
REST, SOAP.
I would appreciate some links to tutorials and piece of advise.
Use SQL Server to manage the data on your desktop and create a web-service in .NET on Visual Studio.
Then connect to the web-service in your application and set/get data from the DB, using web-services. You can use either XML or JSON to transfer your data between the phone and the server.
There is no need for the use of Java Socket API for this.
Links which might be useful :
How to make a web-service in .NET (does not include the implementation in Android) : http://srikanthtechnologies.com/blog/dotnet/wsdaljava.aspx
How to connect your service with Android :
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
http://www.codeproject.com/Articles/304302/Calling-Asp-Net-Webservice-ASMX-From-an-Android-Ap
http://adrianandroid.blogspot.in/2012/05/access-c-net-web-service-in.html
Note: I have never worked on RESTful services. My work has always been on SOAP and hence it remains my preference.
Your final choice of how, exactly, to architect your app, is going to be based on all sorts of things that you haven't included in your questions: your experience, the experience of the other developers in the project, so on and so on.
I will say this, however. REST is deep in the heart of Android. If you decide to go with REST and, possibly, JSON instead of XML (there is, almost certainly, no reason to use byte arrays), you will find that Android's architecture supports you. SOAP and such and you are on your own.
I have to write some web services to support some mobile apps (Android and iOS) that our company will be producing. Because we use Windows/IIS servers the services will be based on WCF/.NET 4. I'm wondering what format will be the easiest to use on the mobile end. I know there's JSON, SOAP, and others, I just don't know which has the best support within a mobile environment. Suggestions?
I intend to have a single set of WCF services which are consumed by both mobile platforms.
Since you're using the .NET-platform on the server, WCF supports sending/receiving XML or JSON messages pretty easily using WebHttpBindings and WebServiceHostFactory to build RESTful services.
For the client platforms - you just need an HTTP Client capable of sending JSON or XML formatted messages to a URL and retrieving a response. There are many libraries that will make this easier to manage, but it depends on the complexities involved in your service.
I would avoid SOAP, but you can easily support it using WCF by adding BasicHttpBinding and a ServiceHostFactory.
For my experience, working with JSON is the best way for iOS and Android.
The server... I would use Java (struts or similar).
Hope this helps
I used the Slim framework (PHP) to serve JSON via RESTish URLs, and the GSON library to convert the data, it was pretty straight forward in my case.
I use apache Camel CXF (web service) & to parse the data I use JAXB.
note: about cxf http://camel.apache.org/cxf.html
We have an EPOD application running on the windows mobile platform. We are now trying to port the same application to the ANDROID platform. The application uses a web service written in .net to communicate with the server and perform various functions. The web service returns a dataset, which we are unable to parse directly in the ANDROID application and view the details. We are trying KSOAP and the JSON ways. If anyone out there has done this before, please help us out. We have be trying to find a solution for a week without any success. If required, we can even modify the web service so that it returns an XML or a JSON object which we can then parse in the ANDORID application.
Any help / sample code will be much appreciated.
Thanks and Regards
Rajendran Menon
.Net services used in interoperable environments (= non .Net clients) should not use datasets. You have already find why. The best you can do is modifying the service to expose simple soap or json = use custom data objets as return values from you service operations.
.net service returning a dataset will be received as an xml document at client end, so without thinking too much about the integration, just grab some code which can call xml webservice and get data from it.
Since there are many ways to solve this, here are additional links that can help:
How to call a .NET web service from android?
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/
http://www.slideshare.net/sullis/connecting-to-web-services-on-android
Let me know if I can help you. I have prior experience with calling .net web services from java.