I'm making an app that searches a database via a webservice call that uses "login" and returns an xml "string".
The wdsl for this call is as follows:
<s:element name="PerformGlobalSearch">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="searchString" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="errorCode" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="errorDescription" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="PerformGlobalSearchResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PerformGlobalSearchResult">
<s:complexType mixed="true">
<s:sequence>
<s:any/>
</s:sequence>
</s:complexType>
</s:element>
<s:element minOccurs="1" maxOccurs="1" name="errorCode" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="errorDescription" type="s:string"/>
</s:sequence>
</s:complexType>
I've generated code using wsdl2objc and it seems to work fine. I just need to know how to accsess the xml returned.
If I NSLog
the responsdata in the "webserviceSvc.m" class it prints the xml.
However, it then returns an object generated by wsdl2objc "PerformeGlobalSearchResponse".
I managed to receive this in code but I can't seem to accsess the xml that it should contain.
-(void) processResponse : (WebServiceSoapBindingResponse *)soapResponse {
NSArray *responseBodyParts = soapResponse.bodyParts;
id bodyPart;
@try{
bodyPart = [responseBodyParts objectAtIndex:0];
}
...
else if([bodyPart isKindOfClass:[xxxWebServiceSvc_PerformeGlobalSearchResponse class]]) {
xxxWebServiceSvc_PerformGlobalSearchResponse* SearchResponse = bodyPart;
NSLog(@"Test: %@", SearchResponse.PerformeGlobalSearchResult);
}
I've tried lots of diferent ways. I need to access the xml and I need to parse it. Parsing I think I've managed while trying diferent solutions.
But how do I accsess the xml? How do I convert PerformGlobalSearchResult to an xml Document?
So the solution to my problem ended up being to change the SOAP code generated so it returned what I needed.
It turned out it got sett up by the WSDL and wsdl2objc to return the worng variable type. I changed it around and ended up using a Dictionary as the return value, because that was a predefined type that was not used. I was then able to prase it with no dificulty.