问:

This is my current call to (asmx) SOAP web service:

NSString *soapMessage =
[NSString stringWithFormat:
@"<?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>"
"<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];
operation.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 respondsToSelector:@selector(myAppHTTPClientDelegate:self:didFailWithError:)]){
[self.delegate myAppHTTPClientDelegate:self didFailWithError:error];
}
}]; [operation start];

But I need to change this to use AFHTTPSessionManager.

I suppose that I need to use this:


UPDATE
NSDictionary *s_request = @{@"par1": [NSString stringWithFormat:@"%i", par1], @"par2": par2, @"par3": par3, @"par4": [NSString stringWithFormat:@"%i", par4], @"par5": par5};

    AFHTTPSessionManager* s_manager = [[AFHTTPSessionManager alloc] 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 need to add method URL or I need to add complete soap message somewhere. What I miss here?

答:

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用AFNetWorking实现请求的更多相关文章

  1. 翻译-使用Spring调用SOAP Web Service

    原文链接: http://spring.io/guides/gs/consuming-web-service/ 调用SOAP web service 本指南将指导你使用Spring调用一个基于SOAP ...

  2. 翻译-使用Spring WebService生成SOAP Web Service

    原文链接:http://spring.io/guides/gs/producing-web-service/ 生成SOAP web service 该指南将带领你使用Spring创建一个基于SOAP的 ...

  3. PHP soap Web Service 使用SoapDiscovery.class.php 生成wsdl文件

    PHP soap web service 使用wsdl文件 demo: ============================================================== 服 ...

  4. REST和SOAP Web Service的区别比较

    本文转载自他人的博客,ArcGIS Server 推出了 对 SOAP 和 REST两种接口(用接口类型也许并不准确)类型的支持,本文非常清晰的比较了SOAP和Rest的区别联系! ///////// ...

  5. 如何在symfony 控制器里面创建soap web service

    通过一些工具将一个控制器设置成一个soap服务将会非常简单.首先,你必须安装了php soap扩展.由于php soap扩展现在不能生成wsdl,你要么自己从头开始创建要模使用第三方生成器. php中 ...

  6. jboss上的soap web service开发示例

    以下示例,由jboss quickstart示例代码得来: 一.创建一个常规的dynamic web项目,建议支持maven ,项目的关键属性参考下图: 二.定义服务接口及参数对象 HelloWorl ...

  7. CXF、Spring整合的SOAP Web Service服务端

    1.建工程,导入CXFjar包 2.服务接口 package com.cxf.soap; import java.util.List; import javax.jws.WebService; @We ...

  8. 使用CXF框架集成Spring实现SOAP Web Service

  9. REST和SOAP Web Service的比较

    1.http://stevenjohn.iteye.com/blog/1442776 2.http://blog.csdn.net/cnyyx/article/details/7483766

随机推荐

  1. [jobdu]二进制中1的个数

    做法是n&(n-1).据说还有变态的查表法:http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html.最后,居然必须用sc ...

  2. SPRING IN ACTION 第4版笔记-第五章BUILDING SPRING WEB APPLICATIONS-005-以path parameters的形式给action传参数(value=“{}”、@PathVariable)

    一 1.以path parameters的形式给action传参数 @Test public void testSpittle() throws Exception { Spittle expecte ...

  3. linux内存管理机制

    物理内存和虚拟内存 我们知道,直接从物理内存读写数据要比从硬盘读写数据要快的多,因此,我们希望所有数据的读取和写入都在内存完成,而内存是有限的,这样就引出了物理内存与虚拟内存的概念. 物理内存就是系统 ...

  4. bzoj2527

    首先环可以变成链来处理,对于l>r的情况就是修改区间[1,r],[l,mx]然后不难想到整体二分,二分答案k,然后算1~k场流星雨对国家的贡献然后判定将国家划分变成子问题解决,没什么难的终于不是 ...

  5. bzoj2749

    根绝欧拉函数的计算式,欧拉函数次方每次就是不断把2消掉,并把其他质因子不断变出2,最终弄成1显然我们先预处理每个数会被弄出多少个2出来,次方=弄出来的2的总数-[一开始是否有2](因为一开始没2的话是 ...

  6. NagiosQL 跨站脚本漏洞

    漏洞名称: NagiosQL 跨站脚本漏洞 CNNVD编号: CNNVD-201312-158 发布时间: 2013-12-11 更新时间: 2013-12-11 危害等级:    漏洞类型: 跨站脚 ...

  7. 利用 Dolby® Digital Plus 提供优质音频体验

    John Deutscher Azure媒体服务首席项目经理 随着媒体设备的增多,一项日益增长的需求是,视频流服务能够向用户提供超高音频质量和具有 5.1 环绕音响的优质内容.通过 Azure媒体 ...

  8. 使用 HTML5、CSS3 和 MathML 在 EPUB 3 中制作版式丰富的出版物

    探索用于高级排版和印刷的新一代开放电子书标准 EPUB 3.0 是最新的行业标准 XML 电子书格式,它采用了 HTML5 和 CSS3,因而融入了现代 Web 技术.它重点关注 XML 驱动的工具包 ...

  9. MongoDB之三(高级操作 聚合、游标)

    一: 聚合 常见的聚合操作跟sql server一样,有:count,distinct,group,mapReduce. <1> count count是最简单,最容易,也是最常用的聚合工 ...

  10. LVS与其他负载均衡软件的区别

    有人在邮件列表问haproxy的作者为何haproxy无论是tcp模式还是http模式,能支撑的并发量都不是太大. Willy回答了这个问题.   Exactly. The difference is ...