• 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: Sending boolean value via XML-RPC using WebServicesCore.framework
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending boolean value via XML-RPC using WebServicesCore.framework


  • Subject: Re: Sending boolean value via XML-RPC using WebServicesCore.framework
  • From: Matt Gemmell <email@hidden>
  • Date: Sat, 28 Sep 2002 22:57:54 +0100

Hi again,

Short version: I fixed the problem. Sorry for any noise. The long version below is for those who might find an explanation useful, or for anyone following this via the archives.

Regarding my earlier post (quoted below), it seems that the boolean wasn't the problem. To pass a boolean value in an XML-RPC call, you can indeed use a CFBooleanRef, set to either kCFBooleanTrue or kCFBooleanFalse.

The "expected Element" error seems to arise when one of the values in the parameter list is malformed in some way. Seems to happen when I pass a string containing HTML tags, for example, which makes some kind of sense since all this is converted to XML before being sent. Still need to play with that a bit.

Once I'd sorted that out, I received another error: NoSuchMethodException. This puzzled me, since I was *definitely* using a valid XML-RPC method name for the service I was attempting to communicate with. It turns out that you'll get this error not only if you use a non-existent method name (as the error's name implies), but also if you pass your parameters in *incorrect order*.

Even if, like me, you use NSDictionary's +dictionaryWithObjectsAndKeys: method, and list your parameters/values in the correct order, there's no guarantee they'll be in that order when the call is sent. So, you need to make use of WSMethodInvocationSetParameters()'s third parameter: an array showing the order that the parameters should be sent in. Just create an NSArray and pass it into WSMethodInvocationSetParameters() as (CFArrayRef)yourArray, and it'll work fine. The array itself is just an array of NSStrings, each of which is the name of one of the parameters. Be sure to add them to the array in the order required by your XML-RPC service (probably using NSArray's +arrayWithObjects: method).

Oh, and if anyone is wondering, the specific service call I'm working with is blogger.newPost, part of the blogger.com (weblogs) API. Find the spec here:

<http://plant.blogger.com/api/>

Hope that helps someone. The little app I'm working on will be open source, no doubt to be released within the next few weeks at my site (<http://www.scotlandsoftware.com/>). If you're reading this in the archives, it may already be up there. :)

Cheers,
-Matt


On Saturday, September 28, 2002, at 09:41 pm, Matt Gemmell wrote:

I'm playing around with XML-RPC calls, using the methods in WebServicesCore.framework (within CoreServices.framework). All has been working fine, up until now that I need to pass a "boolean" value in my XML-RPC call.

I'm using NSDictionary's +dictionaryWithObjectsAndKeys: method to create my parameters dictionary, and for parameters whose type is "string" it works fine to pass in NSStrings. However, I'm unsure as to what type of object I need in order to pass in a value of type "boolean".

When I use WSMethodInvocationSetParameters(), I pass in my params NSDictionary like this: (CFDictionary)params, and it all seems to just work, assuming all the parameters are strings. Now that I need to also have a "boolean" parameter, it falls over.

I've tried a BOOL (which obviously doesn't work in +dictionaryWithObjectsAndKeys:), I've tried an NSNumber +numberWithBool:, and I've even tried passing in a CFBooleanRef set to either kCFBooleanTrue or kCFBooleanFalse. In all these cases, when I do WSMethodInvocationInvoke(), the console just spits this message back at me:

java.lang.Exception: org.xml.sax.SAXParseException: expected Element

I'm a bit lost here, to be honest. Any thoughts on what I'm doing wrong, and what data type to use in an NSDictionary in order to send a "boolean" XML-RPC value, would be much appreciated.

--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Sending boolean value via XML-RPC using WebServicesCore.framework
      • From: Matt Gemmell <email@hidden>
References: 
 >Sending boolean value via XML-RPC using WebServicesCore.framework (From: Matt Gemmell <email@hidden>)

  • Prev by Date: Re: [Newbie] Document Format Advice
  • Next by Date: Re: NSImageView scrolling
  • Previous by thread: Sending boolean value via XML-RPC using WebServicesCore.framework
  • Next by thread: Re: Sending boolean value via XML-RPC using WebServicesCore.framework
  • Index(es):
    • Date
    • Thread