1
我正在應用程序。我想發送圖像到服務器,但我的解析沒有調用,並沒有得到任何response.i嘗試下面的代碼。圖像發送問題到服務器
-(void)callParsing
{
NSData *imgData=UIImageJPEGRepresentation(cameraImageView.image,0.5);
NSLog(@"%@",imgData);
NSString *regestrationString=[[NSString alloc]initWithFormat:@"http://humsomething.netsmartz.us/HumServices.svc/updateimage/vchImage=%@",imgData];
NSURLRequest *regestrationRequest=[[NSURLRequest alloc]initWithURL:[NSURL URLWithString:regestrationString]];
NSURLResponse *regestrationResponce;
NSError *error;
NSMutableData *regestrationData=[[NSMutableData alloc]initWithData:[NSURLConnection sendSynchronousRequest:regestrationRequest returningResponse:®estrationResponce error:&error]];
//[self performXML:regestrationData];
results = [[NSMutableArray alloc] init];
xmlParser = [[NSXMLParser alloc] initWithData:regestrationData];
[xmlParser setDelegate: self];
[xmlParser setShouldResolveExternalEntities: YES];
if([xmlParser parse])
{
NSLog(@"Sucessful");
}
else
{
NSLog(@"Failure");
}
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
if([elementName isEqualToString:@"RegisterUserResult"])
{
if(!soapResults)
{
soapResults = [[NSMutableString alloc] init];
}
[soapResults setString:@""];
recordResults = TRUE;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if(recordResults)
{
[soapResults appendString:string];
NSLog(@"%@",soapResults);
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if([elementName isEqualToString:@"RegisterUserResult"])
{
[results addObject:soapResults];
NSLog(@" REPONSE %@",results);
}
你可以添加更多的細節,如什麼動作調用callParser()?如果([xmlParser parse]) { NSLog(@「Sucessful」);如果([xmlParser parse]) – 2012-08-02 12:17:47
有您看到該行的所有代碼 – 2012-08-02 12:20:11
; } 這行調用解析器,但其結果失敗 – 2012-08-02 12:20:46