Using a web service in an iOS app - ios

How might I go about using a web service in an iPhone app? For example, if I wanted to use a web service that you can use to convert a value into a different unit, how would I go about doing that? For example: http://www.webqc.org/balance.php

It depends what sort of 'web service' it is. If it is a stateless REST style API, passing data in the URL and/or data encoded Json or XML it couldn't be easier, just use NSURLConnection.
Using examples I found on the web I made an application (server and iOS client) - using the NSURLConnection & NSMutableURLRequest, and encoded/decoded data using YAJL. This was pretty easy to get going.
If you don't want to do this using the core libraries directly- there are some frameworks you can use, e.g. RestKit. I've not used it, but it looks good and comes recommended.
If it is a SOAP style web service, this is a lot more complicated as SOAP services often expose a stateful API.
I should say that the example that you show here is not a web-service, whilst it does come with a way of calling it just using a URL - it returns an html page which makes it hard for you to use the results. I presume that you are more interested in a service that returns results encoded as XML or Json or the like.

Related

Programming with swift backend and Angular 2 front. Is it possible?

I didn't find anything on Google saying about it.. so, is it possible?
i.e discard the XCode's Storyboard and use Angular 2 to make apps.
PS: Swift isn't discartable for me due frameworks and done backend code. I am using FFT algorythm from Swift's AudioKit Framework.
Angular2 can be used with any compliant web server written in any language. As long as it speaks HTTP correctly it doesn't matter what it's written in.
Angular2 is a front end JavaScript based technology. As long as you have a web viewer that can render HTML and has a standards compliant JavaScript runtime you can make it talk to your back end.
You can wrap it in an app store compatible package but it will still be a JavaScript app and will connect to your backend in the exact same way that it would if you targeted the browser. The difference is it'll be able to leverage certain device specific capabilities. You will communicate with your backend by sending JSON (any format can be used) back and forth.
The key point is that all communication will be in the form of serialized messages only.
Even if your backend were running on the same device, there's no shared memory space.
Of course since a mobile app can persist it's own state locally it might not need a backend at all. This last point is very domain specific.
It could be posibble if you use Vapor as your backend engine. Take a look at Vapor's website for more info.

exposing part of my parse.com api to other developers via ouath 2.0

It's now trivial to create a web app that sits atop Parse.com. Now that I have this webapp, I want to expose parts of it to other developers via an oauth accesible api. So, they can develop an app that lets my site users 'give them permission' via oauth and they can now access the api.
How would I start going about doing this?
Update: After #Mubix response, I felt the following clarification would help
Currently I am accessing Parse from the server via a REST api, to get around any javascript security issues re:api keys etc. So, the api would be served of a server other than Parse. Also, the server code is in javascript / nodejs. I came across https://github.com/jaredhanson/oauth2orize which seems a likely candidate, was wondering how others are doing it and if anyone has actually gone a further step and integrated Parse access.
Hmmm .. Intereesting question!
Legal:
First of all their ToS doesn't seem to prohibit what you are trying to do but you should read it carefully before you start.
Implementation:
While parse doesn't provide feature to build your own APIs you could implement something yourself. You could treat the third party developers as users of your app. And you can use the ACL to control access.
Problems:
I don't see any way to implement oAuth entirely within parse.
How will third party apps access your API? Ideally you would like them to use a REST interface but with the parse.com REST API you won't be able to manage access to different parts of your data.
Conclusion:
It seems like too much trouble to implement the API entirely within parse. I would suggest that you write a thin API layer that takes care of auth and uses parse as the backend. You can use one of the service side libraries available for parse. eg. PHP Library, Node Parse.

Connect to ActiveResource/ActiveRecord with a Delphi client

I've been looking for some way to let a Delphi program communicate with a RoR service. I could use any of the SOAP libraries out there e.g.: ActionWebService to offer a SOAP service, which I could then use in the Delphi program.
However, this requires one to reimplement all the ActiveRecord methods (such as find) over and over again. This is a hassle even if they are only delegation methods.
Who knows of a simpler / easier / cleaner way?
There is no such bindings, REST isn't a protocol but just convention over http.
I know about activeresource port for Java http://jactiveresource.org/ , but there is no such one for delphi. But you can watch sources of jactiveresource and try develop your own functionality. But you also can create rest client and wrap it with methods you need and unserialize responses into objects.
Here is a short example http://dn.embarcadero.com/article/40449
RoR use REST and MVC design paterns, that means you only need an HTTP client and an XML or JSON library.
I suggest you to watch this video to understand how it works.
http://www.youtube.com/watch?v=YCcAE2SCQ6k
You can keep using existing controllers, you just have to put "application/json" in the "Content-Type" HTTP header to post data and add .json instead of .html to get JSON data instead of HTML.

how to create a web service

I building a website with Ruby on Rails framework.
The site will contain a flash application that will interact with the rails application using web service.
My partner builds the flash application and he told me that the flash application interacts through WSDL file.
I am new to web services. I would like to know how to create the WSDL file, and how to make the interaction between the rails application and the WSDL file.
If you believe that there are better alternatives than SOAP/WDSL, I would like to hear them too.
Thanks,
Oded
Have you Googled how to build web services in Ruby? Here are a few links that come up, all addressing exactly what you want to do:
http://www.tutorialspoint.com/ruby/ruby_web_services.htm
http://www.ibm.com/developerworks/opensource/library/os-ws-rubyrails/index.html
http://searchsoa.techtarget.com/tip/Web-services-with-Ruby-on-Rails
How about you take a look at some of those links, and come back to us if you have further questions.
I do have one elaboration:
My partner builds the flash
application and he told me that the
flash application interacts through
WSDL file.
It sounds like your partner has an incomplete understanding of how Flash can access remote data services. Using a SOAP Web Service with a WSDL is one method, for sure, and here is some documentation on that.
A Flex / Flash application can also make standard HTTP calls, sometimes called REST Web Services. In many cases, REST Web Services will return an XML Document, but that is not required. Any data, including simple text data, can be returned from a REST Web Service.
What many people prefer to do is to use an AMF Gateway with RemoteObject. AMF is a binary format so you'll get much smaller file size transferred back and forth than the alternatives. It also provides for automatic object translation between your server side objects and client side objects. This can be a time saver in development because you don't have to parse data to turn it into something Flex can use easily. RubyAMF is one Ruby implementation of AMF.
You'll be going through more pain than you need to by using WSDL.
Instead, I recommend creating a REST interface that returns json (or xml) -- you'll find in rails it will just work.
So you'll have things like:
/books # returns a list of books. Also do Searching here
/books/1 # return the detail of a book with ID of 1
Search for "REST Rails" and you'll get examples of controllers that will return JSON and XML depending on what the client requests.

Access Web Services on BlackBerry

What are the ways of accessing web services on a BlackBerry device?
I've learned about XML for webservices. We use SAX and DOM parsers in Blackberry. Are there any more ideas like this?
I also want to know what KSOAP is and how to use it on BlackBerry.
AFAIK, kSOAP is a library that lets you post soap requests to your web service. If the service accepts a simple POST request, the easiest way would be to use HttpConnection. Here's a good tutorial
I've also used kXML2 for XML parsing, and that has worked out well for me till now.
Additionally, including 3rd party libraries is a pain (kSOAP and kXML), so here's a guide that will hopefully save you some time.
You can try http://wsclient.neurospeech.com/wsclient/java-android-blackberry/ which supports soap code generation for blackberry with additional library that manages everything, it generates native typed soap client and calling them is very easy. Otherwise you will be spending lot of time in xml to your types and types to xml conversions and so on. Plus date and many things are little complex to handle.

Resources