Pradeep Kumar
Pradeep Kumar

Reputation: 399

WCF service not working for iPhone

I have a WCF service:

http://parentportal.technologyorg.com/ParentPortal.svc

which I have to access and get the data. but unfortunately I am getting some HTML code.

my code is as follows

-(IBAction)doit:(id)sender{

    NSString *soapMessage = [NSString stringWithFormat:@"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://parentportal.technologyorg.com/ParentPortal.svc\"><SOAP-ENV:Body><GetDictionary></GetDictionary></SOAP-ENV:Body></SOAP-ENV:Envelope>"];

    NSURL *url = [NSURL URLWithString:@"http://parentportal.technologyorg.com/ParentPortal.svc"];
                  NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
                  NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

                  [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
                  [theRequest addValue: @"GetStudentTerms" forHTTPHeaderField:@"SOAPAction"];
                  [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
                  [theRequest setHTTPMethod:@"POST"];
                  [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"%@",theRequest);
                  NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if (theConnection) {
     webData = [NSMutableData data] ;
    }
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"___didReceiveResponse");
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSLog(@"Status code %d", [httpResponse statusCode]);

    [webData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    NSLog(@"___didReceiveData");
    [webData appendData:data];
    NSLog(@"%@",webData);
}

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

}

I am not sure whats going wrong were if I NSLog it I am the output as some HTML code.

Can any one help me on this.

Upvotes: 0

Views: 380

Answers (1)

laxonline
laxonline

Reputation: 2653

Try SudzC SOAP-based web service definition WSDL files

Code generation for Objective-C libraries for iPhone development.

Follow the steps below

enter image description here

enter image description here

Upvotes: 1

Related Questions