CONSUMING A WEB SERVICE IN YOUR iOS APPLICATION USING SOAP

Now you're ready to tackle the exciting task of consuming a Web service in your iOS application! In the following Try It Out, you learn how to communicate with the Web service using the SOAP method.

TRY IT OUT: Consuming Web Services Using SOAP

image

  1. Using Xcode, create a Single View Application (iPhone) project and name it WebServices. Use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Select the WebServicesViewController.xib file to edit it in Interface Builder.
  3. Populate the View window with the views as follows (see also Figure 16-3):
    • Label (name it Enter amount to convert)
    • Text Field
    • Round Rect Button (name it Convert)
  4. In Xcode, edit the WebServicesViewController.h file by adding the following bold statements:
    #import <UIKit/UIKit.h>
    
    @interface WebServicesViewController : UIViewController
    <NSURLConnectionDelegate>
    {
        IBOutlet UITextField *txtAmount;
        NSMutableData *webData;
        NSURLConnection *conn;
        NSString *matchingElement;
    }
    
    @property (nonatomic, retain) UITextField *txtAmount;
    
    - (IBAction)buttonClicked:(id)sender;
    
    @end

    image

    FIGURE 16-3

  5. In Interface Builder, perform the following actions:
    • Control-click the File's Owner item and drag it over the TextField. ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.