[iPhone SDK] WebService Options

So anyone reading this, probably has seen the numerous other topics about how the iPhone and SOAP simply is on the complexity level that makes it almost not worth the effort.
Multiple places have recommended: RESTful Web Services
As an alternative method for doing it.
Given I have spent the last multiple years using SOAP driven webservices... going a new path is well.. "interesting"
Does anyone out there have a very basic iPhone code segment, that will show the usage of a RESTful Web Service.
Our long term needs, we have multiple web-service all of which are parameter driven.. With the combination of limited XML functions on the iPhone, we need to do some heavy lifting on the server end... basically putting RESTFul services around our existing SOAP ones.
So any basic examples on using parameter based calls, via RESTful web-service method... would be very much appreciated.
Also... anyone that any other alternatives to this issue... it would also be appreciated as at this point, we are identifying what needs to be done... in order to get all our pieces working, without starting over from scratch.

The appended code adds a record to a Ruby on Rails-based website by treating it as a RESTful web service. (Recent versions of Rails include this capability natively; in this case, I'm exploiting the fact that if you POST an XML data structure corresponding to the structure of a model to a Rails resource, it will create a new resource of the appropriate type.) I've lightly edited it to obscure a few details, but not in any way that will affect you.
The code registers the user's locale with my site so I have some idea of my user base's demographics. I don't check for success or save the result body (which is the return value of sendSynchronousRequest:returningResponse:error:), since my users don't actually care if this process was successful. If you need to include such checks in your app, or want to use the result body, read the URL Loading System article in your documentation.
Keep in mind, though, that there are several approaches to REST. You could send XML back and forth, or you could use the application/x-www-form-urlencoded or multipart/form-data formats used by HTML forms. If the other end of the connection is Mac OS X Server, you could even send NSCoder-serialized objects or XML property lists back and forth! Just use whatever you find easiest with the tools you have available and the requirements you need to meet.
What makes it REST is:
1. I'm specifying what I want to operate on (the set of all registrations) with a URL.
2. I'm specifying the operation I want to perform (adding a record) with the HTTP method. (If I wanted to delete the registration later, I could do it by using the HTTP DELETE method on /registrations/434.xml, or whatever its URL ended up being. Actually, I've forbidden that action except by administrators, but that's beside the point.)
- (NSString*)locale { (code omitted due to irrelevance) }
- (NSString*)xml {
return [NSString stringWithFormat:@"<?xml version="1.0" encoding="UTF-8"?><registration><locale>%@</locale></registration>",
[self locale]];
- (void)sendRegistration {
// This method is invoked as a background thread, so it doesn't
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSURL * url = [NSURL URLWithString:@"http://mycompany.com/registrations.xml"];
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[[self xml] dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse * response;
NSError * error;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// We're ignoring all the outputs because we don't really care.
[pool release];

Similar Messages

  • Downloaded iPhone SDK, ran Xcode, no option for iPhone - Mac OS only!

    Hi everyone,
    I downloaded the free iPhone SDK and ran the installer. Whenever I launch Xcode however, there is no tab for iPhone applications - only Mac OS. I took a peak inside the packages folder in the download and spotted files named "iphone SDK", so I'm confused.
    Any idea on why Xcode runs but there is no option for iPhone?
    Thanks,
    Xeno

    Hello,
    On my PowerPC G5 I have a similar issue where I installed Mac OS X 10.5.6, but after installing the iphone SDK I do not see any refs to iphone when in Xcode.
    I even tried the suggestion here:
    http://3by9.com/85/dont-have-an-intel-machine-but-want-to-code-for-the-iphone-an yway-follow-these-steps/
    This however, resulted in the same issue.
    Any suggestion on how to resolve this would be most appreciated.

  • IPhone SDK:  What are my options for getting help?

    I am an experienced programmer, but new to the mac and iphone. I've installed the sdk, but am not able to build the sample programs. I see from this forum that others have had the same problem, but I don't see an answer. I understand that there are many helpful people on this forum, but what do I do if I can't get my question answered? Should I spend the $99 to enroll and be able to get an answer?
    BTW, my question is about not being able to target the iphone or simulator, and getting an "ibtool cannot open files of this type" error, even though I've installed the iphone and simulator sdks. More at http://discussions.apple.com/thread.jspa?messageID=8559012.
    I appreciate any help, whether it's with my build problem or advice on where I should turn to for help.

    gvsguy wrote:
    Should I spend the $99 to enroll and be able to get an answer?
    If you're really using a G5 iMac, I doubt you'll get much help from Apple. The iPhone SDK is only supported on Intel Macs, so they probably wouldn't be able (or not very willing) to help. Google is more likely to be helpful, assuming someone has found a way to use the iPhone SDK on PPC Macs at all.
    charlie

  • IPhone SDK: Web Services?

    Hiya all,
    Webservices core doesn't seem to be included in the iPhone SDK.
    Anyone have any tips on communicating with a SOAP web service without webservices core? I'm surprised at how little documentation there seems to be online about Cocoa and web services. Any advice would be much appreciated.
    Thanks!
    Pablo

    One option is to port Apache Axis2/C to the iphone:
    http://ws.apache.org/axis2/c/
    It's already been ported to OSX so it may be possible to port it to the iphone:
    http://sahans.blogspot.com/2007/06/axis2c-on-solaris-and-macos.html

  • IPhone SDK custom installation, what do I need?

    FYI, I will be developing iPhone Apps only and don't want to install unnecessary things.
    Options are:
    Developer Tools Essentials (Required.)
    iPhone SDK (Obviously need.)
    System Tools (Do I need? It's checked by default.)
    UNIX Development Support (Do I need? It's checked by default.)
    Mac OS X 10.3.9 Support (Know I don't need, not developing anything for OS X, particularly not an old version.)
    WebObjects (Do I need? It's NOT checked by default.)
    Thanks.

    Hi--
    Welcome to the Apple Discussions.
    System Tools (Do I need? It's checked by default.)
    I would suggest "yes." That's the installer for the performance tools. Shark, especially, can be invaluable for profiling your code.
    UNIX Development Support (Do I need? It's checked by default.)
    I'd suggest "yes." It's command line tools you might want at some point (to help in automating builds, etc.). Some aspects of scripting with OS X can also be made easier if you have the UNIX dev support installed.
    WebObjects (Do I need? It's NOT checked by default.)
    Definitely not, that's a web application framework you'd use if you were building a web site.
    charlie

  • Your Session has Expired - iPhone SDK 3.1.2

    I am new in development. I had my activation done. I try to download from my Mac - Safari and Firefox and I have this error.
    Your session has expired.
    Please return to the ADC Member Site and attempt to download the file again.
    If you feel you received this message in error, please reference this code when contacting the ADC Support Team: V2
    I had been trying for almost a week and still have this error. I had submitted my problem to Apple but no reply from them. Anyone can advice on this.
    regards

    Updating - my issue was solved:
    I've noted that when I was trying to download it through my VPN connection (which connects my internet with my office internet), I forgot to check the "Send all traffic over VPN connection" under the "system preferences - network - My VPN Connection - Advanced...". After checking that this option was "enabled" and all of my network traffic was passing through the VPN, I succeeded downloading it. By that point it must be something wrong with my ISP "Telefonica Espana - Madrid".
    It turns out to be a "intercept proxy" which was implemented by them. As I'm a new subscriber to their service, by default, they redirect my internet connection through this proxy, which they "offer" as a "security" service in order to avoid spamming, fishing websites threats, "parental control" over the web and finally as a "ad blocking proxy". My actual ISP (telefonica espana) offers it by default to their new subscribers and after 30 days they charge us 3,50 EUR/month for this proxy service called "Canguro Net Plus". Actually this clumsy proxy service was blocking my download requests on http://developer.apple.com/iphone. Even after disabling the "Canguro Net Plus" service through its web page configuration, it was still forcing my internet connection to pass through their clumsy proxy. I had to call to their customer service number to request it to be cancelled (They will only accept to cancel it if you call them by phone). After that I'm now able to download the iphone sdk 3.1.3, 2.82 GB in 45 minutes.
    So, if the workaround mentioned above, regarding the change from http to https, doesn't work for you, I suggest you to try a VPN connection in which you must be able to access the internet as well. As a diagnose action you can even try to download it through the "Tor" (The onion router) just to let you verify that through "Tor" you are able to download just a small part of the 2.82 GB. "Tor" is really slow therefore you won't be able to download the iphone sdk (as I said - it's only for a diagnose action). It'll just indicate you that your ISP probably is blocking your download with a clumsy "intercept/cache/transparent proxy" service. Maybe you are able to detect that your ISP is applying some kind of proxy service over your internet connection. Just google it or contact your ISP customer service.
    Good luck!

  • Iphone SDK 3.0 UIKit Error

    Hi I am using iphonesdk_3.0_beta5 SDK. When I try to compile my code using simulator 3.0 option I get following error. The code compiles for rest all simulator option ie 2.0, 2.1, 2.2, 2.2.1 While compiling my code I get following error
    from /Users/videomac/manish/EXPLab/2009-05-27-11-20 myAppLL_2/myAppPrefix.pch:7:
    In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0 .sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:30,
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0. sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollatio n.h:11: error: syntax error before 'AT_NAME' token
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0. sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollatio n.h:19: error: syntax error before '}' token
    /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0. sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollatio n.h:21: fatal error: method definition not in @implementation context
    The errors are located in file UILocalizedIndexedCollation.h which is SDK file.I am using UIKit Framework of SDK 3.0. Can anyone tell me what should I do to remove this error?
    The errors are located in file UILocalizedIndexedCollation.h which is SDK file.I am using UIKit Framework of SDK 3.0. Can anyone tell me what should I do to remove this error?

    I've traced this problem to be the compiler version being used. From what I can tell, REDACTED requires GCC 4.2 while iPhone SDK 2.x only works with GCC 4.0.
    Here's a way to fix this.
    In your Target Info, select Build separator and look for the section Compiler Version. Then:
    1. Select the C/C++ Compiler Version
    2. Set the default to GCC 4.0
    3. At the bottom-left control, hit Add Build Setting Condition
    4. On the left, choose 'Device - iPhone OS 3.0'
    5. On the right, chose GCC 4.2
    6. Repeat steps 3 to 5, now with 'Simulator - iPhone OS 3.0' on step 4.

  • IPhone SDK Help!

    In the video tutorial in iTunes for the introduction to iPhone SDK, it says for my project template to be Cocoa Touch List. I don't have any cocoa touch options displayed on my project templates!

    If you're running the official version, you won't see it anymore. You'll have to manually create the classes.

  • IPhone SDK certifikate problem

    Hello,
    sorry my english is not the best.
    I made a distribution_identity.cer and a developer_identity.cer in the apple developer portal.
    After downloading, i clicked every certificate twice.
    In Xcode i colud not find any certificate in the projekct options.
    Please help me

    excuse me i'm quite new to this community.
    you mean the iphone sdk can not be installed on apple's own hardware?
    is apple switching the focus to x86 architecture? are there any background information that i should take a look at?
    appreciate it.

  • Does iPhone SDK support the feature of data transfer via Bluetooth or USB?

    Hi,
    I'm developing a application in which I want a feature for data transfer either using Bluetooth or USB.
    Does iPhone SDK support this feature of data transfer via Bluetooth or USB?
    Please help me.
    Thanks.

    The SDk doesn't deal with BlueTooth or USB. Your only option is wireless data. (WiFi, 3G, etc)

  • Can't install iphone SDK

    Hello, I'm new programming iphone.
    I have bought a Mac Mini with Mac Os x 10.5.5 operating system and an iphone.
    I've downloaded the "iphone SDK" and when i start the installation process I can't check the option "iphone SDK", but the installer let me check the rest of the options.
    Is the problem my operating system, the Mac mini,....?? do i install another version? with one? The mac os x 10.5.5. is leopard??? or is another??
    Please help me to find the way.
    Thanks

    How new is your Mac Mini? If it's a PowerPC processor, the iPhone SDK won't install.

  • In my iphone 4s search option is disabled how to enable it?

    Hi,
    In my iphone 4s search option is disabled how to enable it?
    Regards,
    KV

    You need to install the Flex sdk
    Check this out
    http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/402540aa-6790-2b10-5fb3-901f52014d13

  • IPhone SDK 2.1 to 3.0

    Hi,
    I downloaded iPhone SDK 2.1 on my Mac a couple of months ago and since 3.0 is out now, how do I go about updating the software to 3.0? Do I completely uninstall 2.1 and do a clean install or is there an option for me to update...I'm assuming within Xcode? sorry, i'm completely new at this.
    J

    Just download the huge SDK package and install. No need to uninstall the old SDK.

  • Problems building w/ Snow Leopard and iPhone SDK 3.0 Snow Leopard

    Suddenly having problems building and codesigning after upgrading to Snow Leopard and iPhone SDK 3.0 Snow Leopard.
    Profile set to Distribution, Device 2.2.1 Distribution, as has worked in the past.
    The build fails with this error:
    Command <com.apple.tools.product-pkg-utility> failed with exit code -1
    The below section is highlighted in Build Results.
    ProcessingProductPackaging /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey/entitlements.plist "/Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timer_harvey/build/iPhoneComprehension.build/Distribution-iphoneos/Kana Listening.build/iPhone_Comprehension.xcent"
    cd /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey
    setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/u sr/bin:/bin:/usr/sbin:/sbin"
    <com.apple.tools.product-pkg-utility> /Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timerharvey/entitlements.plist -entitlements -format xml -o "/Users/harvey/Documents/iPhoneApp_Work/Listening-Hiragana/iPhone_Comprehension_timer_harvey/build/iPhoneComprehension.build/Distribution-iphoneos/Kana Listening.build/iPhone_Comprehension.xcent"
    Any ideas? This is really strange.
    The same error occurs when trying to build for Device - 3.0, and any other version it seems.
    This is especially frustrating as I'm simply trying to update an app that I released before I upgraded.
    I will love whoever helps me forever and ever.
    saikyo

    Found the new SDK on the CD. Now I am running XCode 3.2.
    I'm talking to myself now for the benefit of future readers.
    On the Dev Center I see the note:
    "Important: You will need to re-install the iPhone SDK for Snow Leopard if you plan on developing iPhone applications after upgrading your Mac to Snow Leopard and installing Xcode 3.2."
    So I'm going to download and install the iPhone SDK 3.0 (Snow Leopard) from the SDK downloads area on the Dev Center page. This seems weird to me as it's 3.0... but I'm running 3.2 now... I guess this will just update my 3.2?
    I also notice that when I run XCode 3.2 I don't have Simulator as an option anymore in my profiles.
    Going to go ahead with the update now and see how it goes.

  • IPhone SDK - What is the equivalent of a combo box

    I have a screen where there are quite a few items which are of the multiple-choice type. In other platforms i use a combo box (pick lists) to do this.
    On the iPhone SDK the only thing that comes close is the UIPicketView which is ugly IMHO. it takes too much real estate and too heavy.
    Is this is the only control available now?
    Also does the UIPicker come with an associated control which will launch the picker? What i mean is on other platforms and on the web there is a text field with a button with a down arrow next to it. Clicking either on the text field or the down arrow drops the list down. Is there a similar control on the iPhone which when clicked launches the picker OR do i have to create a button or a custom view which will launch the picker?
    Thanks for reading this and for your feedback.
    -TRS

    I do not believe there is an equivalent of -D in the DB JVM, a possible solution is:
    Load a properties file into the DB using Loadjava, then open this file from your Java code using Properties.load(), then iterate the properties calling System.setProperty().
    Chris

Maybe you are looking for