On 7 Sep 2011, at 14:37, Payal Mundhada wrote:

> Hi Mike,
> 
>  I am creating request as follows:
>  
> @implementation WebService
> -(void)makeRequest
> {
>                   m_URLRequest= [NSMutableURLRequest requestWithURL:url];
>                   [m_URLRequest setHTTPMethod:@"POST"];
>                   [m_URLRequest addValue:SOAPACTION_ISSERVICEAVAILABLE 
> forHTTPHeaderField:@"SOAPAction"];
>                   [m_URLRequest addValue:CONTENTTYPE 
> forHTTPHeaderField:@"Content-Type"];
>                   [m_URLRequest setHTTPBody:[REQUEST_ISSERVICEAVAILABLE 
> dataUsingEncoding:NSUTF8StringEncoding]];
>                  
>                   m_connection =[[NSURLConnection 
> alloc]initWithRequest:m_URLRequest delegate:self];
>                  
>                   m_runLoop =[NSRunLoop currentRunLoop];
>                   m_runLoopRef =[m_runLoop getCFRunLoop];
>       if(m_connection!=nil)
>             {
>                   m_receivedData=[[NSMutableData data] retain];
>                   CFRunLoopRun();
>             }
> }
>  
> In delegate connectionDidFinishLoading handling as follows:
> -(void)connectionDidFinishLoading:(NSURLConnection *)connection
> {
>       @try {
>             CFRunLoopStop(m_runLoopRef);
>             [m_connection release];
>             m_connection =nil;
>       }
> }
> -(void)connection:(NSURLConnection *)connection 
> didReceiveResponse:(NSURLResponse *)response     
> {
>                         [m_receivedData setLength:0];
>             NSHTTPURLResponse *urlResponse=(NSHTTPURLResponse*)response;
>             NSString *str_response=[NSHTTPURLResponse 
> localizedStringForStatusCode:[urlResponse statusCode]];
>            
>             NSLog(@"%@", str_response);
>            
>             NSLog(@"%@", [urlResponse allHeaderFields]);
>             if([urlResponse statusCode]> 200)
>             {
>                   [m_receivedData release];
>                   m_receivedData =nil;
>                   NSLog(@"%@",str_response);
>             }
> }
> @end

What made you decide to write this code in the first place? NSURLConnections 
are intended to be asynchronous. You're trying to force it to be synchronous in 
a way that I suspect Cocoa doesn't expect.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to