• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to release a WSMethodInvocation and its result properly?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to release a WSMethodInvocation and its result properly?


  • Subject: How to release a WSMethodInvocation and its result properly?
  • From: Mustafa Tuğrul Özşahin <email@hidden>
  • Date: Wed, 17 Mar 2010 14:33:59 +0200

Hi,
I have this method to send a soap request to a web service and I want it to return an NSArray, and cause no memory leaks. Am I releasing everything properly (especially soapReq and its result)? And how should I change this method not to make it minimum memory consuming?
Thanks everyone.

-(NSArray *)getProjects
{
   
    NSArray *pa;
    NSURL *url = "" URLWithString:[NSString stringWithFormat:@"http://%@:8191/service",serverIP]];
    NSString *method = @"GetProjects";
    NSString *namespace = @"http://www.mmm.com/api/";
    NSString *action = "" href="http://www.mmm.com/api/Service/GetProjects">http://www.mmm.com/api/Service/GetProjects";
    NSDictionary *reqHeaders = [NSDictionary dictionaryWithObject:action forKey:@"SOAPAction"];
    WSMethodInvocationRef soapReq = WSMethodInvocationCreate((CFURLRef)url,
                                    (CFStringRef)method,
                                    kWSSOAP2001Protocol);
    WSMethodInvocationSetProperty(soapReq, kWSSOAPMethodNamespaceURI, (CFStringRef)namespace);
    WSMethodInvocationSetProperty(soapReq, kWSHTTPExtraHeaders, (CFDictionaryRef)reqHeaders);
    WSMethodInvocationSetProperty(soapReq,    kWSHTTPFollowsRedirects, kCFBooleanTrue);
    CFDictionaryRef resCF = WSMethodInvocationInvoke(soapReq);
   
    NSDictionary *result = [(NSDictionary *)resCF retain];
    CFRelease(resCF);
   
    pa = [NSArray arrayWithObject:[[[result objectForKey:@"/Result"]objectForKey:@"GetProjectsResult"]objectForKey:@"a:Project"]];
   
    CFRelease(soapReq);
    CFMakeCollectable(soapReq);
    [url release];
    [method release];
    [namespace release];
    [action release];
    NSLog(@"sr released");
    return pa;
}

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Next by Date: Re: How to release a WSMethodInvocation and its result properly?
  • Next by thread: Re: How to release a WSMethodInvocation and its result properly?
  • Index(es):
    • Date
    • Thread