How call SOAP based web-Service using PhoneGap in iPhone? - iphone

I am newbie for PhoneGap and our client's requirement is to access SOAP based web-service in iPhone using PhoneGap, basically accessing the web-service using javascript, any help would be appreciated.

calling a webservice with phonegap is the same than calling it directly from your browser (but you have to think about the same orign policy).
Some performance implications are here to consider was well because processing big chunks of xml in javascript on mobile phones might be slow. So you could use some kind of weserver to talk to the webservice end send some simplified json to your phone or you can take a look at this tutorial from ibm describing how to call a webservice directly from javascript:
http://www.ibm.com/developerworks/webservices/library/ws-wsajax/

as i know, call web service from mobile device just like call web service from out side of that web service. So we need cross domain.
To cross domain, we need the support from server side, such as: Jsonp or proxy

Related

Web API and Native API compatibility

Ok. Here is my situation:
I am developing an embedded device, which provide a service. It will provide some web based services to a client (a smart phone).
Currently we are planning to implement a REST server in the device so that web applications can easily access and use the services provided by the device.
In the future, we plan to add a display and a better processor to our embedded device so that we can run the web applications on the device itself.
We want to maintain application compatibility - i.e all the current web applications should work on the device without any modifications.
Is there a better way to implement this than using REST and HTTP? I am worried about performance running both the server and the client on the device.
If you take care to separate the REST Api code from the actual service code, your newer device can interface (direct call) directly with the service instead of wrapping everything into HTTP and REST.
This being said, you can always try an implementation using you REST api and validate if performance is adequate. If it is, you do not even need to add the indirection.

RESTful webservice hosted on iPhone

My question is, Is there a way to host RESTful webservice on iPhone? This is possible in java based mobile.
RESTful Web Services Implementations in Mobile Devices
EDIT:
I want to host and consume RESTful web services from/within different mobile devices. I cant use socket for my project.
I normally use ASIHTTPRequest for webservice on iPhone, it supports RESTful. Give it a try, I am sure you will like it.
You'll want to check out something like this:
http://cocoawithlove.com/2009/07/simple-extensible-http-server-in-cocoa.html
Or, implement your own HTTP server on iOS (I suppose).
It's definitely possible.

iOS Device communication

I am keen to get some apps built that can communicate with other devices/ web etc. i have played around with FTP and can get so far. But what is the best way to do this? We don't have any Servers with databases etc, but do have a site that we are currently uploading and downloading files to.
can anyone suggest a good/ better way to get the device to send/ receive files?
thanks
sam
If it's HTTP communication you're wanting to do, the simplest and most powerful tool is ASIHTTPRequest.
HTTP is the protocol your web browser uses to talk to web servers. If you have a site you're storing and downloading files at, it's almost certainly HTTP you're talking to it.
For iOS device to device communication one can use Bump API.
EDIT: I don't know of a generic framework for device <-> server communications, but having built applications that use web services of other providers like Yelp, Yahoo, Google Maps, I would say the way to go for this is to have REST based web services which exchange data in JSON format.

How does iphone apps interact with server?

I am a new programmer who is new to iPhone development and server stuff. I have a lot of questions to ask.
You don't have to answer all the questions; any help is appreciated!
How does iPhone apps interact with server?
Is there a particular kind of server i should use to interact iphone app with server?
If there is no particular kind of server then what kind of server can be used?
What are their advantages and disadvantages?
What should the iPhone app (which is the client) do in order to interact with the server?
How does the server know which iPhone to send data to?
What should the server do in order to interact with iPhone app (client)?
Your best bet is to have your iPhone make web requests of a web server. Your iPhone app acts just like a web browser, making http requests to a web server, and parsing the response.
I'm building an app right now that hits PHP scripts I've written that do database work, etc, and return JSON objects. It's not fancy--I could have built a whole SOAP or RPC web service, but I didn't do that, it just makes GET requests with query-string arguments.
There are handy libraries you want to know about. Google "iPhone JSON" to find the JSON library written by Stig Brautaset, that's the one most people seem to be using. Also, rather than putting yourself through all the hoops that the iPhone's built-in web client framework requires, go get ASIHTTPRequest, a very powerful and MUCH simplified web client library.
As a general rule, you want to do as much processing on the server as possible. For instance, there's a place in my app I'm searching for events happening within a user-specified range of their local coordinates ("within 10 miles of me"). I wrote PHP to build a latitude/longitude bounding box, and query from the database based on that. That's WAY faster than bringing a bunch of events down and then asking Core Location to calculate their distance from where I'm standing.
You've asked quite a few questions so I'll try my best to answer them all:
First, you need to be a bit clearer, what type of server are you talking about? Email server, web server, lolcat server, it depends.
At the basic level, the iphone communicates over the internet. The internet uses Internet Protocol, and there are two standard protocols built atop of IP: Transmission Control Protocol, and User Datagram Protocol. Each has it's own uses and functions.
TCP/IP and UDP/IP make up the backbone of internet communication.
A more specific application protocol is built atop of these two internet protocols, with a specific format to a given application. For example, HTTP is the standard protocol for transferring HTML and other Web information between a web server to a web browser client, over TCP.
So, your iPhone would use whatever protocol is required to commuincate with the server. For more common server communication, the iOS SDK provides methods to construct messages (for example if you wish to make an HTTP request to a web server, you can use initWithContentsOfURL to send a GET request).
If you built a custom server, then you will need construct the required message protocol on the iphone, and send it to the server, using either TCP or UDP (whatever your custom server expects).

Do most iPhone apps communicate via web services?

Do most of the popular iPhone apps that communicate with a back end Internet server communicate via web services? I was assuming this was the case.
Some apps I'm thinking about would be: Facebook, Bloomberg, NY Times, ESPN, etc.
Well a web service is just an API - Application Programming Interface
The apps you mentioned would probably all implement their own API for exchanging data between the client and the server so yeah, I would say the answer is yes. You can implement your own API via XML, JSON etc. You just need to define the protocol. You can implement existing concepts in your own apps. Have a look at the following:
REST
SOAP
JSON
Most of the Apps that I've written use web services of some sort, I prefer being RESTful, but I have been forced to use SOAP.