You are not logged in.

  • Login

Dominic Ley


  • "Dominic Ley" started this thread

Posts: 2

Occupation: Developer/Consultant

  • Send private message


Monday, July 4th 2011, 2:12pm

iOS Webservice Request - soapgate Q! (DBGETMAILINFO)

Type: XCode 4.x project
Version: 0.2-ALPHA
Size: 59 Kb
License: Apache License, Version 2.0
Author: QKom GmbH (

This example shows the minimal implementation of a SOAP-based web service request using NSURLConnection / XMLParser. It triggers a DBGETMAILINFO on our demo server You can easily port the given example to your working environment

Improved versions of this code will be added to this article soon.

    recordResults = FALSE;

    NSString *soapMessage = [NSString stringWithFormat:
        @"<?xml version="1.0" encoding="utf-8"?>\n"
        "<soapenv:Envelope\ xmlns:soapenv=""\ xmlns:urn="urn:DefaultNamespace"\ xmlns:xsi="" xmlns:xsd="" xmlns:soap="">\n"
        "</soapenv:Envelope>\n", nameInput.text

    NSURL *url = [NSURL URLWithString:@""];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue: @"DBGETMAILINFO" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    if( theConnection )
        webData = [[NSMutableData data] retain];
        NSLog(@"theConnection is NULL");

    [nameInput resignFirstResponder];


-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    [theXML release];

        [xmlParser release];

    xmlParser = [[NSXMLParser alloc] initWithData: webData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities: YES];
    [xmlParser parse];

    [connection release];
    [webData release];
Dominic Ley has attached the following images:
  • SOAP_ExampleRequest_01.jpg
  • SOAP_ExampleRequest_02.jpg
  • SOAP_ExampleRequest_03.jpg
Dominic Ley has attached the following file:
everyone's first vi session. ^C^C^X^X^X^XquitqQ!qdammit[esc]qwertyuiopasdfghjkl;:xwhat