O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required