это метод веб-сервиса и полученная информация ... ![method SOAP 1.1](https://i.stack.imgur.com/MieNb.png)
![method HTTP POST](https://i.stack.imgur.com/Yh4tl.png)
![data retrieved](https://i.stack.imgur.com/Gfvx1.png)
почему нельзя вставить строку слов вUserFullname не может быть получено?
xmlparsing в 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{
}
Вывод:
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
я просто не понимаю, почему не получается строка данных для UserFullname ..в моих кодах есть ошибки или что-то?спасибо за вашу помощь ...