WebServicesCore problem

Todd Ditchendorf itod at mac.com
Fri Feb 2 09:26:30 PST 2007


I suppose it's possible that your server XML-RPC impl is not sending  
a fault string... you need to see the raw XML-RPC response (and  
request too) to see where the problem lies.

Here's what i would do before sending the request:

     // for good measure, make the call follow redirects.
     WSMethodInvocationSetProperty(inv,    kWSHTTPFollowsRedirects,  
kCFBooleanTrue);

     // set debug props
     WSMethodInvocationSetProperty(inv, kWSDebugIncomingBody,      
kCFBooleanTrue);
     WSMethodInvocationSetProperty(inv, kWSDebugIncomingHeaders,  
kCFBooleanTrue);
     WSMethodInvocationSetProperty(inv, kWSDebugOutgoingBody,      
kCFBooleanTrue);
     WSMethodInvocationSetProperty(inv, kWSDebugOutgoingHeaders,  
kCFBooleanTrue);

This will cause it to follow redirects and also include raw req and  
res in the result dicitonary. Print the entire result dictionary to  
see those.


BTW, I just blogged about WebServices Core and HTTP auth (somewhat  
related) the other day on my blog:

http://www.ditchnet.org/wp/2007/01/30/example-code-webservices-core- 
cfnetwork-for-soap-http-auth-on-os-x/


Todd Ditchendorf

Scandalous Software - Mac XML Developer Tools
http://scan.dalo.us



On Feb 2, 2007, at 9:14 AM, Graham J Lee wrote:

> 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;
>> }
>>
> _______________________________________________
> MacOSX-dev mailing list
> MacOSX-dev at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/macosx-dev



More information about the MacOSX-dev mailing list