Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use this code:</p> <pre><code>-(IBAction)btnclick1:(id)sender { recordResult=FALSE; greeting.text=@"Processing"; NSString *soapMessage=[NSString stringWithFormat:@" WEB SERVICE ",nameInput.text,passInput.text]; NSLog(@"%@",soapMessage); NSURL *url=[NSURL URLWithString:@"http://SOME URL.asmx"]; NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url]; NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMessage length]]; [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:@"http://tempuri.org/webservicename" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection=[[NSURLConnection alloc]initWithRequest:theRequest delegate:self]; [myActivity startAnimating]; if(theConnection) { webData=[[NSMutableData data]retain]; } else { NSLog(@"theConnection is NULL"); } [nameInpt resignFirstResponder]; [passinpt resignFirstResponder]; } ----- -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConenction"); [connection release]; [webData release]; } -(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=nil; } xmlParser=[[NSXMLParser alloc]initWithData:webData]; [xmlParser setDelegate:self]; [xmlParser setShouldResolveExternalEntities:YES]; [xmlParser parse]; [myActivity stopAnimating]; [webData release]; //webData = nil; [connection release]; } -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName { if([myTxt1.text isEqualToString:@"webservresult"]) { if(!soapResult) { soapResult=[[NSMutableString alloc]init]; } recordResult=TRUE; } } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(recordResult) { [soapResult appendString:string]; } } -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if([myTxt1.text isEqualToString:@"wsresult"]) { recordResult=FALSE; greeting.text=[NSString stringWithFormat:@"webservicename Result is:%@",soapResult]; [soapResult release]; soapResult=nil; } } </code></pre> <p>that's it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload