ios - Run Two urls in single method -
i finding way run 2 services in method 1 after post images 1 one . after 1st service need response need pass response 2nd service.
the code i've used post run single service post single image
nsstring *url=[nsstring stringwithformat:@"http://37.187.152.236/userimage.svc/insertobjectimage?%@",requeststring]; nslog(@"url1%@",url); nsmutableurlrequest *request = [[nsmutableurlrequest alloc] init] ; [request seturl:[nsurl urlwithstring:url]]; [request sethttpmethod:@"post"]; // create 'post' mutablerequest data , other image attachment. nsstring *boundary = @"---------------------------14737809831466499882746641449"; nsstring *contenttype = [nsstring stringwithformat:@"multipart/form-data; boundary=%@", boundary]; [request setvalue:contenttype forhttpheaderfield:@"content-type"]; nsdata *data = uiimagejpegrepresentation(chosenimage1, 0.2f); [request addvalue:@"image/jpeg" forhttpheaderfield:@"content-type"]; nsmutabledata *body = [nsmutabledata data]; [body appenddata:[nsdata datawithdata:data]]; [request sethttpbody:body];
some similar questions may there in stackoverflow need different.
flow of method must *run 1st url --> generate response ({userid:"20",message:"success"} ) --> run 2nd url *
help me, in advance everyone.
you can call second method respect response of first method
-(void)webservicecall { webapicontroller *obj=[[webapicontroller alloc]init]; nsmutabledictionary *imageparameter = [nsmutabledictionary dictionary]; nsdata *imagedata = uiimagepngrepresentation(self.productimageview.image); [imageparameter setvalue:imagedata forkey:@"image"]; [obj callapiwithimage:@"upload.php" withimageparameter:imageparameter withoutimageparameter:nil successcallback:@selector(upload_response:response:) anddelegate:self]; }
response web service:
-(void)upload_response:(nsstring *)apialias response:(nsdata *)response { nsmutabledictionary *jsondictionary=[nsjsonserialization jsonobjectwithdata:response options:nsjsonreadingmutablecontainers error:nil]; nsstring *responsemsg=[[nsstring alloc] initwithstring:[jsondictionary objectforkey:@"message"]]; if ([responsecode isequaltostring:@"success"]) { [self calltosecondwebservice]; } }
second webservice:
-(void)calltosecondwebservice { }
Comments
Post a Comment