objective c - send audio using web service using AFNetworking -


hy, have audio need send using webservice along other inputs. after doing search understood cannot send nsdata using xml soap message downloaded afhttprequest classes , followed examples on internet, not working. web service using:

<?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>     <addlocation2 xmlns="http://tempuri.org/">       <userid>int</userid>       <name>string</name>       <voicemsg>base64binary</voicemsg>     </addlocation2>   </soap:body> </soap:envelope> 

this code using send data , other parameters:

   nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"test" oftype:@"m4a"];  nsdata *audio = [nsdata datawithcontentsoffile:filepath];  afhttprequestoperationmanager *manager = [afhttprequestoperationmanager manager];  nsstring *urlstring = @"http://host.com/websr/service.asmx?op=addlocation2";//[webservice getaudiourl]; nsdictionary *parameters = @{@"userid": @2,                              @"name": @"usertest",                              };  manager.requestserializer = [afhttprequestserializer serializer]; manager.responseserializer = [afhttpresponseserializer serializer];  manager.responseserializer.acceptablecontenttypes = [nsset setwithobjects:@"text/html", @"audio/m4a", nil]; [manager post:urlstring parameters:parameters constructingbodywithblock:^(id<afmultipartformdata> formdata) {      if (audio) {         [formdata appendpartwithfiledata:audio name:@"voicemsg" filename:[nsstring stringwithformat:@"test.m4a"] mimetype:@"audio/m4a"];     } } success:^(afhttprequestoperation *operation, id responseobject) {     nslog(@"success %@", responseobject);     nslog(@"operation %@", operation.responsestring);  } failure:^(afhttprequestoperation *operation, nserror *error) {     uialertview *alert=[[uialertview alloc]initwithtitle:@"failure" message:@"sending failure" delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil];     [alert show];     nslog(@"failure %@, %@", error, operation.responsestring); }];  [self dismissviewcontrolleranimated:no completion:nil]; 

the app crashing excess bad access on when reaches if statement containing data in class afurlresponseserialization.h:

- (bool)validateresponse:(nshttpurlresponse *)response                 data:(nsdata *)data                error:(nserror *)error { bool responseisvalid = yes; nserror *validationerror = nil;  if (response && [response iskindofclass:[nshttpurlresponse class]]) {     if (self.acceptablecontenttypes && ![self.acceptablecontenttypes containsobject:[response mimetype]]) {         nslog(@"[response url] %@", [response url]);          if ([data length] > 0 && [response url]) {                 ...} 

any advice appreciated. thank you.

you don't need use afhttprequest classes. requirement send base64binary data on network, web service says. follow below link, helpful. http://iosdevelopertips.com/core-services/encode-decode-using-base64.html


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -