SOAP Web Service implements requests with afnetworking

Source: Internet
Author: User
Tags soap

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.