Re: Complex data for webservices
Re: Complex data for webservices
- Subject: Re: Complex data for webservices
- From: Jeff LaMarche <email@hidden>
- Date: Mon, 21 Apr 2008 09:30:28 -0400
Niklas:
I'm no expert on Web Services on Objective-C, but I've been playing
around with them a bit. One thing that I have discovered is that
CFTypeRef is not _always_ a dictionary. In some cases, it wants a
string. For example, if you run WSMakeStubs on the National Weather
Service's WSDL :
http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl
Several of the CFRefType arguments in the class methods actually need
to be specified as NSStrings not as NSDictionary instances, something
I only discovered after a lot of failed attempts to use it.
Unfortunately, the documentation for WSMakeStubs and the web services
part of CoreServices, AFAIK, doesn't give detailed information on how
to know when CFRefType refers to a dictionary and when it's something
else like an NSString in your generated stubs.
Without knowing what your web service looks like I don't think I can
be any more helpful than that. Have you used the debugger to step
through the setParameters: method while it's running? You might be
able to tell what it's looking for by doing that. That was how I
figured out to pass in a space delimited list as an NSString rather
than a dictionary.
Sorry I can't be more helpful,
Jeff
On Apr 21, 2008, at 8:15 AM, Niklas Saers wrote:
Just a short PS
On Apr 21, 2008, at 1:45 PM, Niklas Saers wrote:
TestAuthentication *WS = [[TestAuthentication alloc] init];
[WS setParameters:param];
NSLog(@"isComplete == %d, isFault == %d, true == %d", [WS
isComplete], [WS isFault], YES);
I hadn't noticed that static functions were also present in the
stubs, so I tried them but got the same results. I added a NSLog
there as well, and got the same result:
+ (id) TestAuthentication:(CFTypeRef) in_parameters
{
id result = NULL;
TestAuthentication* _invocation = [[TestAuthentication alloc]
init];
[_invocation setParameters: in_parameters];
result = [[_invocation resultValue] retain];
NSLog(@"debug: isComplete: %d, isFault: %d, true: %d",
[_invocation isComplete], [_invocation isFault], YES);
[_invocation release];
return result;
}
output: debug: isComplete: 1, isFault: 1, true: 1
To decouple this from the complex types, I wrote a little webservice
in C# for MS-IIS called testInt that I've verified with SOAP Client
from Scandalous Software that behaves correctly:
[WebMethod]
int testInt() {
return 5;
}
that returns
<soap:Envelopexmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema
instance"xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
-<soap:Body>
-<testIntResponse xmlns="webservices.mydomain.com/myService">
-<testIntResult>-5</testIntResult>
</testIntResponse>
</soap:Body>
</soap:Envelope>
Again I added debug info to the code:
+ (id) testInt:(CFTypeRef) in_parameters
{
id result = NULL;
testInt* _invocation = [[testInt alloc] init];
[_invocation setParameters: in_parameters];
result = [[_invocation resultValue] retain];
NSLog(@"debug: isComplete: %d, isFault: %d, true: %d", [_invocation
isComplete], [_invocation isFault], YES);
[_invocation release];
return result;
}
and again it failed: debug: isComplete: 1, isFault: 1, true: 1
My call in this case was:
[Service1Service testInt:[[NSDictionary alloc] init]];
That is, an empty dictionary, so no parameters. I tried passing nil,
but then it just crashed
For the authentication I called:
NSDictionary *serviceDict = (NSDictionary*) [myServiceService
TestAuthentication:param];
NSLog(@"Entries: %d", [serviceDict count]);
and I got: "Entries: 0"
So either way isFault returns YES, and either way I get an empty
NSDictionary back. Why is this, and how do I get it to return
correctly? (you'd think it'd be easy enough calling an "int
function()" ;-) )
Cheers
Nik
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden