this is the web service method and the info retrieved…



why cant the string of words in UserFullname cant be retrieved?
xmlparsing in xcode:
//connect to webservice
NSString *soapMsg = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<RetrieveUser xmlns=\"http://dev.cel.nie.edu.sg/\">"
"<password>%@</password>"
"</RetrieveUser>"
"</soap:Body>"
"</soap:Envelope>", passWordField.text];
//requesting
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://dev.cel.nie.edu.sg/projects/VideoApp/VideoWebService.asmx"]];
//message length??
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
//building the post xml
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://dev.cel.nie.edu.sg/RetrieveUser" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
//connection
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
//[req release];
if(conn){
webData = [[NSMutableData data] retain];
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
[webData setLength:0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
[conn release];
[webData release];
NSString * errorString = [NSString stringWithFormat:@"Please connect to the internet to continue."];
UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"" message:errorString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
xmlParser = [[NSXMLParser alloc] initWithData:webData];
[xmlParser setDelegate:self];
[xmlParser setShouldProcessNamespaces:NO];
[xmlParser setShouldReportNamespacePrefixes:NO];
[xmlParser setShouldResolveExternalEntities:NO];
[xmlParser parse];
[conn release];
[webData release];
}
-(void)parserDidStartDocument:(NSXMLParser *)parser{
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//retrieve lecturer's ID, name and photo according to the password. Retrieve from web service
currentElement = [elementName copy];
if ([elementName isEqualToString:@"UserID"]) {
// clear out our story item caches...
currentID = [[NSMutableString alloc] init];
currentName = [[NSMutableString alloc] init];
lectFullName = [[NSMutableString alloc] init];
currentImg = [[NSMutableString alloc] init];
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
// save the characters for the current item...
if ([currentElement isEqualToString:@"UserID"]) {
[currentID appendString:string];
}else if([currentElement isEqualToString:@"Username"]){
[currentName appendString:string];
NSLog(@"lect username: %@", currentName);
}else if([currentElement isEqualToString:@"UserFullname"]){
[lectFullName appendString:string];
NSLog(@"lectname: %@", lectFullName);
}else if([currentElement isEqualToString:@"UserImage"]){
[currentImg appendString:string];
NSLog(@"lect img: %@", currentImg);
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
}
Output:
2011-11-04 16:45:16.314 MyLauncher[4538:707] lect username: tom
2011-11-04 16:45:16.317 MyLauncher[4538:707] lect img: http://dev.cel.nie.edu.sg/projects/VideoApp/LecturerImages/ID2--DaPe--2011-11-03-Ti7e--04-07-38.jpg
i just dont understand y its not retrieving the data string for UserFullname… is there some error in my codes or something? thx for ur help…
Ok solved it… in the ftp server i not only need to add the webservice .asmx file but in the ftp http docs folder I have to put the webservice .dll and .pbd files into the bin folder…