Doing Web Services in Objective C

The examples for web services in Objective C in Xcode 2 are pretty lame. I am surprised that things are not cleaner – the WebKit is very sweet and cool.
I took one of the examples and refactored it to make it really cool. I will post code in the blog in my next two posts.
This is a mix of C++ and Objective C. I am not an expert in either in Xcode2 having learned Xcode 4 days ago. If someone smarter than me wants to redo this Apple event code using purely Objective C – that is fine with me. I would actually like that refactored code.
This is all Creative commons public domain – sample code stuff. Use, tear up reuse, don’t sue me.
This is the meat of host things are used again – note my weird dialect where I switch back form C, C++, and Objective C. I am still a newbie and fall back to things I know like fprintf from time to time :)


// Java Signature in jws
// public String mymethod(String id, Integer i, Double d)
OSErr err;
AEDesc soapParms;
err = createSoapParameters(&soapParms);
err = addSoapParameter(&soapParms, “id”, typeChar, “fred”);
int i=25;
err = addSoapParameter(&soapParms, “i”, typeSInt32, &i);
double d=123.456;
err = addSoapParameter(&soapParms, “d”, typeIEEE64BitFloatingPoint, &d);
char buffer[100000];
char errorMessage[1024];
err = makeSoapCall(url, “mymethod”, &soapParms ,buffer, sizeof(buffer), errorMessage, sizeof(errorMessage), false, true);
AEDisposeDesc(&soapParms);
if ( err == noErr ) {
fprintf(stderr,”Success String = %s!\n\n”, buffer);
} else {
fprintf(stderr,”Error String = %s!\n\n”, errorMessage);
}