WebServicesCore problem
Graham J Lee
leeg at thaesofereode.info
Fri Feb 2 09:14:28 PST 2007
Hi, I'm trying to connect to an XML-RPC service using WebServicesCore
in synchronous mode (actually, I'm just trying to get it to connect
to see whether I understand the documentation, the specific way I
invoke it will change over time). The code I have below fails, but
with no reason in the kWSFaultString, which the docs say *will* be
set on failure. :-(
One thing which may affect the behaviour of WSCore is that the
connection is over SSL (on a nonstandard port, too), and that the
certificate is self-signed. Is there a way to get WSCore to ignore
the certificate?
Thanks,
Graham.
> #include <CoreServices/CoreServices.h>
>
> int main (int argc, const char * argv[]) {
> // insert code here...
> CFURLRef url = CFURLCreateWithString(NULL,CFSTR("https://server:
> 1234/XMLRPC"),NULL);
> CFStringRef method = CFSTR("Service.Method");
> WSMethodInvocationRef inv = WSMethodInvocationCreate
> (url,method,kWSXMLRPCProtocol);
>
> // add the service ID and password to the parameters
> int sid = 123;
> CFNumberRef serviceID = CFNumberCreate
> (NULL,kCFNumberIntType,&sid);
> CFStringRef pw = CFSTR("likeiwouldpostthattoamailinglist;-)");
>
> CFMutableArrayRef order = CFArrayCreateMutable(NULL,2,NULL);
> CFMutableDictionaryRef params = CFDictionaryCreateMutable(NULL,
> 2,NULL,NULL);
>
> CFDictionaryAddValue(params,CFSTR("Service"),serviceID);
> CFDictionaryAddValue(params,CFSTR("Password"),pw);
>
> CFArrayAppendValue(order, CFSTR("Service"));
> CFArrayAppendValue(order, CFSTR("Password"));
>
> WSMethodInvocationSetParameters(inv,params,order);
> //right, should be able to invoke the method now
>
> CFDictionaryRef result = WSMethodInvocationInvoke(inv);
>
> CFStringRef returnStr;
> //let's see if that worked
> if(WSMethodResultIsFault(result))
> {
> printf("Didn't work.\n");
> returnStr = CFDictionaryGetValue(result, kWSFaultString);
> printf("Fault: %s\n",CFStringGetCStringPtr
> (returnStr,kCFStringEncodingUTF8));
> }
> else
> {
> printf("Worked!\n");
> returnStr = CFDictionaryGetValue(result,
> kWSMethodInvocationResult);
> printf("%s\n",CFStringGetCStringPtr
> (returnStr,kCFStringEncodingUTF8));
> }
>
> return 0;
> }
>
More information about the MacOSX-dev
mailing list