RE: WebServices Question (plus some additional details)
RE: WebServices Question (plus some additional details)
- Subject: RE: WebServices Question (plus some additional details)
- From: "Mark" <email@hidden>
- Date: Sat, 17 Jan 2004 15:12:07 -0700
Tom,
First of all this isn't really an answer to your question but I will
ultimately face the same problem dealing with consuming collections of
objects returned from a .Net web service so I'm very interested in this
thread.
For now I'm just trying to prototype a simple web service consumer and your
example below is only the third I've been able to find between Apple
developer documentation, books (Mac OSX Advanced Development Techniques),
and the web (this forum). Your posting brought me closer to understanding a
solution than any other reference to date.
Perhaps you can give me a hand with the basics which will then allow me to
pursue the same issue you are currently facing as another pair of eyes.
My .Net web service is the sample web method called HelloWorld which simply
returns a string "Hello World". I've tried using WSMakeStubs, a sample in
the Mac book mentioned above and the code you included in your post (with
modifications to remove the parameters).
My particular problem is that the dictionary returned from
WSMethodInvocationInvoke has five keys but none of them are what I expect. I
expect to call [result objectForKey:(NSString*)kWSMethodInvocationResult] to
get a dictionary which I would then use to look up "HelloWorldResult" but
when I look at the keys from the result set using the following snippet:
NSDictionary *result = (NSDictionary
*)WSMethodInvocationInvoke(soapcall);
NSLog([NSString stringWithFormat:@"%@",[result allKeys]]);
I get the following keys:
(
"/kWSHTTPResponseMessage",
"/WSDebugOutBody",
"/WSDebugInBody",
"/WSDebugInHeaders",
"/WSDebugOutHeaders"
)
I'm not sure where to turn off the debug information but it at least gave me
confidence that I was indeed getting information from my web service. In
fact, the most frustrating aspect is that I can see "Hello World" embedded
in the SOAP message associated with the /WSDebugInBody key.
The /kWSHTTPResponseMessage gives me <NSCRType:0x3787f0> which I though I
could cast into NSDictionary and then get my HelloWorld object. But no luck
- I make the case bu then the "objectforKey" selector is not recognized. I
can only assume at this point that it's not a dictionary object.
Any help on this front would be greatly appreciated. I will gratefully
return the favor if and when I discover a solution to the collection problem
that you are facing. As I mentioned before, I ultimately have to solve that
very same problem for myself very soon.
-----Original Message-----
From: email@hidden
[
mailto:email@hidden] On Behalf Of Tom Ryan
Sent: Tuesday, December 30, 2003 4:37 PM
To: email@hidden
Subject: Fwd: WebServices Question (plus some additional details)
Whoops, somehow this got mixed in with another thread. sorry about that
folks!
--Tom Ryan
Does anyone have any light to bring to this?
Begin forwarded message:
>
From: Tom Ryan <email@hidden>
>
Date: December 29, 2003 6:24:55 PM EST
>
To: email@hidden
>
Subject: WebServices Question
>
>
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.
_______________________________________________
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.
_______________________________________________
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.