Ask:
This is the my current call to (ASMX) SOAP Web service:
NSString *soapmessage = [NSString stringWithFormat: @ "<?xml version=\" 1.0\ "encoding=\" utf-8\ "?>" "<so Ap: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>" "<save xmlns=\" http://www. Myapp.com/\ ">" "<par1>%i</par1>" "<par2>%@</par2>" "<par3>%@</par3>" "</Save>" "</soap:Body>" "</soap:Envelope>", Par1, Par2, PAR3]; Nsurl *url = [Nsurl urlwithstring:@ "Http://....asmx"]; Nsmutableurlrequest *request = [Nsmutableurlrequest Requestwithurl:url]; NSString *msglength = [NSString stringwithformat:@ "%lu", (unsigned long) [SoapMessage length]]; [Request AddValue: @ "text/xml; charset=utf-8" forhttpheaderfield:@ "Content-type"]; [Request Addvalue:msglength forhttpheaderfield:@ "Content-length"]; [Request sethttpmethod:@ "POST"]; [Request Sethttpbody: [SoapMessage datausingencoding:nsutf8stringencoding]]; Afhttprequestoperation *operation = [[Afhttprequestoperation alloc] Initwithrequest:request];o Peration.responseserializer = [Afxmlparserresponseserializer serializer]; [Operation setcompletionblockwithsuccess:^ (afhttprequestoperation *operation, id responseobject) {if ([Self.delegate respondstoselector: @selector (myapphttpclientdelegate:didupdatewithweather:)]) {[Self . Delegate Myapphttpclientdelegate:self Didupdatewithweather:responseobject]; }} failure:^ (Afhttprequestoperation *operation, Nserror *error) {if ([Self.delegate respon Dstoselector: @selector (myAppHTTPClientDelegate:self:didFailWithError:)]) {[Self.delegate Myapphttpclientdelegat E:self Didfailwitherror:error]; } }]; [Operation start];
But I need to the change
AFHTTPSessionManager
.
I suppose that I need to use this:
UPDATE
nsdictionary *s_request= @{@"Par1": [NSStringstringWithFormat:@"%i",par1], @"Par2":par2, @"Par3":Par3, @"PAR4": [NSStringstringWithFormat:@"%i",PAR4], @"PAR5":PAR5}; Afhttpsessionmanager*S_manager= [[AfhttpsessionmanagerAlloc]Init]; [S_manager POST:@"Http://192.168.10.26/mywebservice/myservice.asmx?op=MethodName"Parameters:s_request Success:^(Nsurlsessiondatatask *Task,ID responseobject) { NSLog(@"done!"); }Failure:^(Nsurlsessiondatatask *Task, Nserror *Error) { NSLog(@"FAILED%@,%@", [Error Localizeddescription], [Error Localizedfailurereason]); }];
This code always fail. Getting error 500
. Do I just the need to add method URL, or I need to the Add complete SOAP message somewhere. What am I miss here?
For:
You need to pass parameter in Dictionary like in the following example:
Nsdictionary *request = @{@ "Email": self.email.text, @ "password": Self.password.text}; [Manager Post:login Parameters:request success:^ (afhttprequestoperation *operation, id responseobject) { NSLog (@ "done!");} failure:^ (afhttprequestoperation *operation, Nserror *error) { NSLog (@ "Failed to log in:%@", operation.responsestring);}];
SOAP Web Service implements requests with afnetworking