我正在开发一个应用程序。我想将图像发送到服务器,但我的解析没有调用,也没有得到任何响应。我尝试以下代码。
-(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);
}