Using HttpClient to invoke a webservice in an android app - android

I am new to android & web services.I I want to create an android app which consume a webservice using HttpClient.
Yet i am confused with, how to do this. I'll explain what i've needed to do.
Say,we have a webservice at http://www.w3schools.com/webservices/tempconvert.asmx
WSDL url=http://www.w3schools.com/webservices/tempconvert.asmx?WSDL
What I need is to call the method "FahrenheitToCelsius" & return values from it in an android app.Can't i do this using HttpClient? Since it seems to get only the HTTP methods like GET and POST.
When I search on this ,I found the below site as a more frequent suggestion. But it doesn't contain ,what I need to do.
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/
(I could call "FahrenheitToCelsius" method & return values using ksoap library.But now i need to do it using HttpClient too)

To clarify- When you connect to a webservice via its WSDL file, you're consuming a very specific kind of webservice— specifically, a SOAP webservice.
The typically way to connect to a SOAP webservice is to either find a library in your language of choice, or find a utility that will use the WSDL to generate code for you that communicates with the webservice.
One popular utility for connecting to SOAP on Android is called ksoap-android.

Related

How does android retrieve data from a website?

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

How to use Android call WCF ..?

How to write Android call WCF (It's a “.svc“ web) code?
I tried to read related articles.
Finally with the library (ksoap2), but still can not succeed.
If the WCF (.svc web) contains a function (Adder).
How do I call the function (Adder)?
The question is not so much how can Android call WCF? rather how can Android call a SOAP Service? Try googling that. By definition it should not matter how the SOAP service is implemented; .NET or not; Java or not.
Same applies if the WCF service is JSON instead of SOAP.

Pass parameters Using HTTP request

Hi i am new to android programming and i would like to know how to call a web service and pass parameters to the web service to obtain the return result in form of an XML.
I previously used Ksoap lib and SOAP request but thats not working correct so now i am trying the HTTP method.
Please Help
You will want to read up on the Apache HttpClient.
Beyond that its a matter of making sure the device and server are generating messages that the other side can correctly parse.
Is the server an existing service? Or are you designing that as well?
check the following in which you will use HTTP post request & you will get response in the form on XML
Android HttpPost: how to get the result

I want to implement a RESTful webservice do i need something om my server running to handle requests , like with SOAP

I want to implement a RESTful webservice for an Android App using JSON. Do i need something om my server running to make for example a GET request work , like with SOAP is the case. I have read something on servlets but i don't know if this is neccesary or not.
If you will be using PHP on the server then you can write a RESTful service with a PHP application framework like Kohana, CodeIgniter, CakePHP etc. There are quite a few.
These frameworks have built in functions for encoding results in JSON format and they support the REST approach out of the box.
If you prefer I'm sure there are also similar IIS and .NET based approaches too.
If you query your own server, then you need to first program your server to handle requests. On the other hand, if you query a 3rd party RESTful server, then all you need is create the appropriate http request, send it and handle the response.
Servlets are used for Java EE based implementations of servers. You can implement your server in any programming language or framework you want.

Android using kSoap with webservices other than .NET

I'm trying to make an application that's making a connection to an XML-page that I've built with Progress database. I've tried accessing it with kSoap2, following this tutorial (http://seesharpgears.blogspot.com/2010/10/web-service-that-returns-array-of.html).
It doesn't really go into my Progress Procedure, so I don't get any response, so I'm wondering if this kSoap actually works with other webservices than .NET webservices?
You can find my webservice class over here http://pastebin.com/50rhLCFr.
My domain class is built exactly like the tutorial and the Progresscode works if I save the file to XML.
Thank you very much!
I have worked with a number of web services alongside android and this is my usual debugging process:
Build up a request manually and POST it using some software such as SoapUI to verify it works
once you have successfully constructed a working request you can then simply HTTP POST it from within android
store your own request templates and fill them out using string replace
this technique avoids using Ksoap, which I have found to be quite annoying!

Categories

Resources