SOAP web service用AFNetWorking实现请求
问:
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实现请求的更多相关文章
- 翻译-使用Spring调用SOAP Web Service
原文链接: http://spring.io/guides/gs/consuming-web-service/ 调用SOAP web service 本指南将指导你使用Spring调用一个基于SOAP ...
- 翻译-使用Spring WebService生成SOAP Web Service
原文链接:http://spring.io/guides/gs/producing-web-service/ 生成SOAP web service 该指南将带领你使用Spring创建一个基于SOAP的 ...
- PHP soap Web Service 使用SoapDiscovery.class.php 生成wsdl文件
PHP soap web service 使用wsdl文件 demo: ============================================================== 服 ...
- REST和SOAP Web Service的区别比较
本文转载自他人的博客,ArcGIS Server 推出了 对 SOAP 和 REST两种接口(用接口类型也许并不准确)类型的支持,本文非常清晰的比较了SOAP和Rest的区别联系! ///////// ...
- 如何在symfony 控制器里面创建soap web service
通过一些工具将一个控制器设置成一个soap服务将会非常简单.首先,你必须安装了php soap扩展.由于php soap扩展现在不能生成wsdl,你要么自己从头开始创建要模使用第三方生成器. php中 ...
- jboss上的soap web service开发示例
以下示例,由jboss quickstart示例代码得来: 一.创建一个常规的dynamic web项目,建议支持maven ,项目的关键属性参考下图: 二.定义服务接口及参数对象 HelloWorl ...
- CXF、Spring整合的SOAP Web Service服务端
1.建工程,导入CXFjar包 2.服务接口 package com.cxf.soap; import java.util.List; import javax.jws.WebService; @We ...
- 使用CXF框架集成Spring实现SOAP Web Service
- REST和SOAP Web Service的比较
1.http://stevenjohn.iteye.com/blog/1442776 2.http://blog.csdn.net/cnyyx/article/details/7483766
随机推荐
- UVA 11294 Wedding
给n对夫妇安排座位,其中0h,0w分别表示新郎,新娘.同一对新郎,新娘不能坐在同一侧,而且互为通奸关系的人不能同时坐在新娘对面. 这道题目真是掉尽节操啊,,,欧美的氛围还是比较开放的. 分析: 首先说 ...
- Android ListView(Selector 颜色)
listview_color.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...
- Java缓存--JCS
添加外部包: jcs-1.3.jar concurrent-10.3.jar cache.cff # optional region "myCache" specific conf ...
- C# Eval在asp.net中的用法及作用
Eval( " ")和Bind( " ") 这两种一个单向绑定,一个双向绑定,bind是双向绑定,但需数据源支持 ASP.NET 2.0改善了模板中的数据绑定操 ...
- 很受欢迎的Linux笔记(短小精悍)
http://blog.csdn.net/xsl1990/article/details/8274028 如何知道所使用的LINUX是哪个发行版? lsb_release -a 查找某个文件的另类方法 ...
- Android-相册效果(图片缩放 自由滑动)
先上图: 很多时候 我们会有这么一个需求: 展示一组图片 每个Item的图片 可以自由拉伸 滑动 焦点不冲突 网上有很多实现方法 通过自定义Gallery和ImageView来实现 个人不是很推荐 在 ...
- ActionBar官方教程(1)简介及各区域介绍
Action Bar The action bar is a window feature that identifies the user location, and provides user a ...
- Android 导出db并查看内容
1.导出sqlite的db文件: 使用工具DDMS,切换到DDMS,显示File Explorer窗口,找到/data/data/应用名/databases/数据库名,点击导出按钮,导出文件. 2.使 ...
- HTML <!--...--> 注释标签
HTML <!--...--> 注释标签 实例 HTML 注释: <!--这是一个注释,注释在浏览器中不会显示--> <p>这是一个段落</p> 浏 ...
- C#创建https请求并使用pfx证书
常规情况下创建Web请求,并获取请求数据的代码如下: WebRequest req = WebRequest.Create(url); req.Timeout = 15000; WebResponse ...