Web interface Invocation

Source: Internet
Author: User

NSString *strgetpritype= @ "<?xml version=\" 1.0\ "encoding=\" utf-8\ "? >\n"

"<soap12:envelope xmlns:xsi=\" http://www.w3.org/2001/xmlschema-instance\ "xmlns:xsd=\" http://www.w3.org/2001/ Xmlschema\ "xmlns:soap12=\" http://www.w3.org/2003/05/soap-envelope\ ">"

"<soap12:Body>"

"<getprjtype xmlns=\" http://tempuri.org/\ "/>"

"</soap12:Body>"

"</soap12:Envelope>";

NSString *maglength=[nsstring stringwithformat:@ "%lu", (unsigned long) [strgetpritype length]];

Afhttprequestoperationmanager *manger=[afhttprequestoperationmanager Manager];

Manger.responseserializer = [[Afhttpresponseserializer alloc] init];

[Manger.requestserializer setvalue:@ "application/soap+xml; charset=utf-8" forhttpheaderfield:@ "Content-Type"];

[Manger.requestserializer setvalue:maglength forhttpheaderfield:@ "Content-length"];

[Manger.requestserializer setvalue:@ "application/soap+xml; charset=utf-8" forkey:@ "Content-Type"];

[Manger.requestserializer setvalue:maglength forkey:@ "Content-type"];

Nsmutableurlrequest *request=[manger.requestserializer requestwithmethod:@ "POST"

urlstring:@ "Http://192.168.2.214:86/webservice/WebService.asmx"

Parameters:nil

Error:nil];

[Request Sethttpbody:[strgetpritype datausingencoding:nsutf8stringencoding];

Afhttprequestoperation *operation=[manger Httprequestoperationwithrequest:request

success:^ (afhttprequestoperation *operation, id responseobject) {

NSString *response=[[nsstring alloc]initwithdata: (NSData *) Responseobject encoding:nsutf8stringencoding];

NSLog (@ "%@,====%@", operation,response);

}

failure:^ (afhttprequestoperation *operation, Nserror *error) {

NSString *response=[[nsstring alloc]initwithdata: (NSData *) [Operation Responseobject]encoding:nsutf8stringencoding ];

NSLog (@ "%@,%@,%@", operation,error,response);

}];

[Manger.operationqueue addoperation:operation];

Web interface Invocation

Related Article

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.