WebServicesCore: Getting an xsd:dateTime into a request
WebServicesCore: Getting an xsd:dateTime into a request
- Subject: WebServicesCore: Getting an xsd:dateTime into a request
- From: Chris Hanson <email@hidden>
- Date: Mon, 16 Dec 2002 13:04:11 -0600
WebServicesCore is *really* frustrating.
I've generated some stubs using WSMakeStubs for a web service I built
using WebObjects 5.2 Direct to Web Services. This web service, as
one of its parameters, takes an xsd:dateTime.
So of course, the first thing I tried was just passing an NSDate as
an argument.
This doesn't work. WebServicesCore generates an xsd:timeInstant
instead of an xsd:dateTime. That is, it generates:
<creationDate xsi:type="xsd:timeInstant">2002-11-26T04:34:00Z</creationDate>
instead of
<creationDate xsi:type="xsd:dateTime">2002-11-26T04:34:00Z</creationDate>
which is what I need for WebObjects not to freak out.
So then I try to pass a dictionary, and pass the secret special
undocumented kWSRecordType key in it to get it to generate an element
of my own devising. This doesn't work. It generates a record, NOT
an element, and there's NO BLOODY WAY to make it generate an element.
Passing the key kWSRecordType with the value "xsd:dateTime" winds up
giving me
<creationDate xsi:type="xsd:dateTime">
<creationDate xsi:type="xsd:string">2002-11-26T05:01:29Z</creationDate>
</creationDate>
which is OBVIOUSLY wrong.
So last night I had an inspiration, and thought I could make it work
using a custom serializer. So, I wrote a serializer like this:
CFStringRef SerializeDictCallback(WSMethodInvocationRef invocation,
CFTypeRef obj,
void *info)
{
NSDictionary *dict = (NSDictionary *)obj;
NSString *elementType = [dict objectForKey:@"BDWSElementType"];
NSString *result = NULL;
if ([elementType isEqualToString:@"BDWSPassThrough"]) {
// passThrough is a string to pass straight through
result = [[dict objectForKey:@"passThrough"] retain];
} else if ([elementType isEqualToString:@"BDWSElement"]) {
// Name is the name of the element
// Type is the type of the element
// Value is the value of the element
NSString *name = [dict objectForKey:@"name"];
NSString *type = [dict objectForKey:@"type"];
NSString *value = [dict objectForKey:@"value"];
result = [[NSString stringWithFormat:
@"<%@ xsi:type=\"%@\">%@</%@>",
name, type, value, name] retain];
} else {
// Let the default serializer handle it
result = nil;
}
return (CFStringRef) result;
}
and added it to my invocation before setting the invocation's
parameters like this:
invocation = [[CreatePerson alloc] init];
ref = [invocation getRef];
WSMethodInvocationAddSerializationOverride(ref,
CFGetTypeID((CFDictionaryRef) creationDate), // <- an NSDictionary
SerializeDictCallback,
NULL);
[invocation setParameters:shortName
in_password:password
in_fullName:fullName
in_creationDate:creationDate];
And then I tried invoking it. Of COURSE it didn't even call my
serialization override! What was I thinking? That an API would just
work the way it looked like it was designed (since it's not like I
had any documentation to go on)?
Is it just that WebServicesCore doesn't work? Am I really asking the
bloody impossible? Or is there some trick to using it that I'm just
not seeing?
-- Chris
-- EXTREMELY frustrated
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Application Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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.