WebServices Question
WebServices Question
- Subject: WebServices Question
- From: Tom Ryan <email@hidden>
- Date: Mon, 29 Dec 2003 18:24:55 -0500
Hi folks,
I've got this troublesome question that's been bugging me for a while,
and hope that someone here can help me out:
I'm writing an app that hits a .NET Web Service. I can successfully
return results for single objects:
* A class defined on the server:
** LLSession
--property: username
--property: password
--property :siteid
--property: passwordExpiresInDays
This, as I said, works just fine.
However, when I try to return a *collection* of objects (actually a
.NET DataSet or XmlDataDocument), while I see in the debug headers that
everything in the DataSet/XmlDataDocument is returned, the NSDictionary
into which the results are being poured only returns the *last* item in
that set of data. I'm looking to grab the data and dump into an
NSBrowser or NSOutlineView...
Does anyone have any experience with this?
Here's the code I use to invoke the WebService method:
==============BEGIN INVOKE =============
- (NSDictionary *)invoke:(NSString *)host
methodName:(NSString *)methName
methodNamespace:(NSString *)ns
soapAction:(NSString *)action
parameters:(NSDictionary *)params
paramsOrder:(NSArray *)orderOfParams
{
WSMethodInvocationRef soapCall;
NSURL *soapURL;
NSDictionary *result;
NSDictionary *dictToReturn;
soapURL = [NSURL URLWithString:host];
soapCall = WSMethodInvocationCreate((CFURLRef)soapURL,
(CFStringRef)methName, kWSSOAP2001Protocol);
NSDictionary *headers = [NSDictionary dictionaryWithObject:action
forKey:@"SOAPAction"];
NSString *keyResult = [NSString stringWithFormat:@"%@Result",
methName];
WSMethodInvocationSetParameters(soapCall, (CFDictionaryRef)params,
(CFArrayRef)orderOfParams);
WSMethodInvocationSetProperty(soapCall, kWSSOAPMethodNamespaceURI, ns);
WSMethodInvocationSetProperty(soapCall, kWSHTTPExtraHeaders, headers);
result = (NSDictionary *)WSMethodInvocationInvoke(soapCall);
dictToReturn = [result objectForKey:(NSString
*)kWSMethodInvocationResult];
return [dictToReturn objectForKey:keyResult];
}
============== END INVOKE =============
Here is the method to return the (as defined in .NET) XmlDataDocument:
============= BEGIN loadCHILDREN ===============
- (NSDictionary *)loadChildren:(LLSession *)sess volID:(int)v
nodeID:(int)n {
NSString *methodName = @"getChildren";
NSString *soapNameSpace =
@"urn:mycompany.it.livelinkaccess.webservices";
NSString *soapAction = @"urn:
mycompany.it.livelinkaccess.webservices/getChildren";
NSNumber *vid = [NSNumber numberWithInt:v];
NSNumber *nid = [NSNumber numberWithInt:n];
NSArray *aryUserVals = [NSArray arrayWithObjects:
[session sessionAsDictionary],
vid,
nid,
nil];
NSArray *aryUserKeys = [NSArray arrayWithObjects:
@"session",
@"volumeId",
@"nodeId",
nil];
NSDictionary *childDict = [NSDictionary
dictionaryWithObjects:aryUserVals forKeys:aryUserKeys];
NSArray *paramsOrder = [NSArray arrayWithObjects:@"session",
@"volumeId", @"nodeId", nil];
NSDictionary *dict = [connect invoke:hostname
methodName:methodName
methodNamespace: soapNameSpace
soapAction: soapAction
parameters:childDict
paramsOrder:paramsOrder];
return dict;
} // this method works fine for data objects that are not collections
============= END loadCHILDREN ===============
Thanks in advance for your help,
Tom Ryan
_______________________________________________
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.