![]() Here’s how the sample code gets the fault info. (See the XML-RPC spec for more about faults.)Ī fault is something the XML-RPC server returns. The final type of error is an XML-RPC fault. For instance, if you use an incorrect RPC URL when calling a method, you may get an HTML page returned instead of the XML-RPC response you were expecting. One potential cause of this error is that you actually get HTML. This happens when you get invalid XML from the server. Message = [NSString server returned an unexpected response code: %i.",Īnother type of error is a parse error. Here’s the sample code handling download errors. There are several types of possible errors.Ī download error could be that, simply, no data was returned, even though a 200 response was returned by the server.Ī download error could also be that a response other than 200 was returned: 404, for example. ![]() If there was an error of some kind, then the sample code handles errors in displayError. The call to returnedObject is the whole point of this whole thing-it’s the value (as a Cocoa object) returned by the XML-RPC server. The sample code gets the returned value like this: Success means there were no download or parse errors and the XML-RPC server did not return a fault object. Then it checks to see if the call succeeded. It’s not something users usually want to see. The sample callback first outputs the raw XML request and response to the Console. getStateNameCallbackĬallbacks take one parameter, the XMLRPCCall object. ![]() Your callback is always called on the main thread, even though the XML-RPC transport is run on another thread. The call to invokeInNewThread does two things: first it calls the XML-RPC method, then it calls your code: it calls your callback specified by the target and callbackSelector. In XML-RPC parameter order matters: there are no named parameters. In this example there’s just one parameter, but parameters should always be an array-even when there are no parameters. [rpcCall setMethodName: it sets the parameters. XMLRPCCall *rpcCall = initWithURLString: rpcURL] The sample code creates an XMLRPCCall object given the URL (as a string) of the XML-RPC server. getStateNameĬalling an XML-RPC method requires a few things: the URL of the XML-RPC server, a method name, and a list of parameters. The following example code comes from XMLRPCCocoa.m, the code for the demo app that comes with the download. (But the below should be enough to get you started.) How to make an XML-RPC call The base64 encoding and decoding code is a slightly modified version of the code by Dave Winer. (A pre-built CURLHandle framework is included in the download.) This class uses CURLHandle for the actual HTTP transport. As a set of Cocoa classes it’s easier to use than a C API, and you can create sub-classes. Using this XML-RPC code has other benefits: it’s Open Source, so you can see the code. (NetNewsWire’s weblog editor uses XML-RPC heavily it’s how external editors work with weblogs.) ![]() We fully expect this (and other smaller bugs) to get fixed-but we couldn’t wait. In some cases when a method response contains an empty element, there’s a crash. Why not use Apple’s XML-RPC implementation?Īt this writing (7 March 2003) the implementation of XML-RPC in Apple’s WebServicesCore has a crashing bug. It’s a way of calling remote procedures via HTTP and XML. This XML-RPC code is used in NetNewsWire. Included is a simple application that demonstrates how to use it. It’s an Open Source (BSD license) XML-RPC client class. All of this code is really, really old! And not very good! Youâre better off looking somewhere else! ![]()
0 Comments
Leave a Reply. |