Reputation: 31
I'm newbie in Objective C. I'm trying to consume an webservice with sudcz. I've got and Webservice server created in PHP an MySQL and now I'd like to comunicate with the server and getting a relevant results.
When calling a method i'm getting corrent XML response from the server but returned object of type ArrayOfString seems to be empty. NSLog prints just <ArrayOfString></ArrayOfString>, i'm assuming sudzc wasn't albe to parse xml in to a aproporiate form therefore the returned object is empty, am I wrong ? or I just cant see or cope with the returned object ? Has someone got any clue ?
If any materials needed i'll post them. Thx.
Added :
CXMLElementNode* element = [[Soap getNode: [doc rootElement] withName: @"Body"] childAtIndex:0];
if(deserializeTo == nil) {
output = [Soap deserialize:element];
} else {
NSLog(@"Deserialize to : %@", deserializeTo);
if([deserializeTo respondsToSelector: @selector(initWithNode:)])
//problematic section
element = [element childAtIndex:0];
NSLog(@"NSSstring element : %@", element);
output = [deserializeTo initWithNode: element];
} else {
NSString* value = [[[element childAtIndex:0] childAtIndex:0] stringValue];
NSLog(@"NSSstring value : %@", value);
output = [Soap convert: value toType: deserializeTo];
}
NSLog(@"output : %@", output);
}
I think the problematic section is where I putted comments problematic section. Because object element is xml element and after calling output = [deserializeTo initWithNode: element], nothing happens, NSLog(output) prints the same output as printed NSLog(deserializeTo) before calling message initWithNode: element on object deserializeTo I suspect SoapObject instance method initWithNode that it doesn't work as it should, because my deserializeTo is instance of class RSiArrayOfstring a that class is subset of SoapObject and it delegates this message to parent class (SoapObject) and the implementation of this message in SoapObject is :
// Called when initializing the object from a node
- (id) initWithNode: (CXMLNode*) node {
if(self = [self init]) {
}
return self;
}
i can't see any manipulation with argument node
OUTPUT from debugger during executing this code :
2012-02-08 20:22:03.166 URS[1170:b603] Deserialize to : <ArrayOfstring></ArrayOfstring>
2012-02-08 20:23:17.258 URS[1170:b603] NSSstring element : <CXMLElement 0x5d7b920 [0x59701b0] return <return arrayType="SOAP-ENC:Array[6]" type="SOAP-ENC:Array">< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">1 - Elektroúdržba</item>< /item>< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">2 - Zámočnícka dielňa< /item>< /item>< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">3 - Údržba žeriavov</item>< /item>< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">6 - Zámočnícká dielňa H4< /item>< /item>< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">4 - Mechanici< /item>< /item>< item arrayType="xsd:string[1]" type="SOAP-ENC:Array">< item type="xsd:string">5 - Údržba CNC< /item>< /item>< /return>>
2012-02-08 20:56:11.353 URS[1170:b603] output : < ArrayOfstring>< /ArrayOfstring
Upvotes: 1
Views: 908
Reputation: 21
Hi i just ran into the same issue.
I found that
[[Soap getNode: [doc rootElement] withName: @"Body"]
omits the namespace of tags. So in my case the XML part looks like this:
<SOAP-ENV:Body>....
Changing the above line to:
[[Soap getNode: [doc rootElement] withName: @"SOAP-ENV:Body"]
helped in my case. Allthough i am not sure if the namespace varies for different soap implementations.
cheers!
Upvotes: 2