You are not logged in.

  • Login

Dear visitor, welcome to Qkom GmbH Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Dominic Ley

Consultant

  • "Dominic Ley" started this thread

Posts: 2

Occupation: Developer/Consultant

  • Send private message

1

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 (info@qkom.de)
Website: http://www.qkom.de

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

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

-(IBAction)buttonClick:(id)sender{
    recordResults = FALSE;

    NSString *soapMessage = [NSString stringWithFormat:
        @"<?xml version="1.0" encoding="utf-8"?>\n"
        "<soapenv:Envelope\ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\ xmlns:urn="urn:DefaultNamespace"\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n"
        "<soapenv:Header/>\n"
        "<soapenv:Body>\n"
        "<urn:USERNAME>%@</urn:USERNAME>\n"
        "</soapenv:Body>\n"
        "</soapenv:Envelope>\n", nameInput.text
    ];
    NSLog(soapMessage);

    NSURL *url = [NSURL URLWithString:@"http://domino.flexdomino.net/SOAPGateQ_20.nsf/DominoUtilityWebservices?wsdl"];
    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];
    else
        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];
    NSLog(theXML);
    [theXML release];

    if(xmlParser)
        [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