• 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
Re: Passing arrays via WSMethodInvocationInvoke() [WebServicesCore]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing arrays via WSMethodInvocationInvoke() [WebServicesCore]


  • Subject: Re: Passing arrays via WSMethodInvocationInvoke() [WebServicesCore]
  • From: Dan Korn <email@hidden>
  • Date: Mon, 26 Oct 2009 15:49:51 -0500

Quoting myself:

1. Is there any Cocoa object, or combination of objects, that I can
use to generate the required XML without having to call
WSMethodInvocationAddSerializationOverride()?

I still haven't found an answer to this.

2. Is there something built-in I can call in my serialization override
function to properly encode the data, escaping XML control characters
with entities and such, in the same way that the default serialization
works?

After a lot of experimenting with NSArchiver and NSCoder to no avail, I finally stumbled upon the CFXMLCreateStringByEscapingEntities() function, which seems to do what I want, although I still think I must be missing some "NS" way of doing this. So, here's my updated serialization function:


static CFStringRef _arrayToXML(WSMethodInvocationRef invocation, CFTypeRef obj, void *info)
{
if (obj != nil && (CFGetTypeID(obj) == CFArrayGetTypeID()))
{
NSArray* array = (NSArray*)obj;
NSMutableString* result = [[NSMutableString alloc] initWithFormat:@"<%s>", "%@"];
for (int i = 0; i < [array count]; i++)
{
NSString* rawString = [array objectAtIndex:i];
CFStringRef markup = CFXMLCreateStringByEscapingEntities (kCFAllocatorDefault, (CFStringRef)rawString, NULL);
[result appendFormat:@"<string>%@</string>", markup];
}


      [result appendFormat:@"</%s>", "%@"];
      return (CFStringRef)result;
    }

    return NULL;
  }

Again, apologies if there's a more appropriate forum for this; please redirect me.

Thanks,
Dan

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Passing arrays via WSMethodInvocationInvoke() [WebServicesCore] (From: Dan Korn <email@hidden>)

  • Prev by Date: Re: Alternative to stringWithContentsOfURL
  • Next by Date: [iPhone] Why so many calls?
  • Previous by thread: Passing arrays via WSMethodInvocationInvoke() [WebServicesCore]
  • Next by thread: Force subviews to stay in place during live resize
  • Index(es):
    • Date
    • Thread