问:

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. easyui源码翻译1.32--Window(窗口)

    前言 扩展自$.fn.panel.defaults.使用$.fn.window.defaults重写默认值对象.下载该插件翻译源码 窗口控件是一个浮动和可拖拽的面板可以用作应用程序窗口.默认情况下,窗 ...

  2. Axure RP Pro 6.5修改站点地图,只显示需要的节点

    1. 原始页面   2. 原始代码(用记事本打开生成原型所在文件夹下的data\sitemap.js) var sitemap = (function() { var _ = function() { ...

  3. SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-003- 上传文件multipart,配置StandardServletMultipartResolver、CommonsMultipartResolver

    一.什么是multipart The Spittr application calls for file uploads in two places. When a new user register ...

  4. ANDROID_MARS学习笔记_S01原始版_004_TableLayout

    1.xml <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android ...

  5. ANDROID_MARS学习笔记_S01原始版_020_Mp3player001_歌曲列表

    一.项目设计 二.歌曲列表简介 1.利用java.net.HttpURLConnection以流的形式下载xml文件为String 2.自定义ContentHandler-->Mp3ListCo ...

  6. 139. Word Break

    题目: Given a string s and a dictionary of words dict, determine if s can be segmented into a space-se ...

  7. Android 去除list集合中重复项的几种方法

    因为用到list,要去除重复数据,尝试了几种方法.记录于此... 测试数据: List<"}; List<string> li2 = new List<string& ...

  8. 正则表达式(javascript)学习总结

    正则表达式在jquery.linux等随处可见,已经无孔不入.因此有必要对这个工具认真的学习一番.本着认真.严谨的态度,这次总结我花了近一个月的时间.但本文无任何创新之处,属一般性学习总结. 一.思考 ...

  9. java数组或集合返回空的问题

    在有返回值的情况下,平时我写代码基本遇到错误什么都是返回null,我因为我觉得把数组或集合这个初始化占空间. 但是我发现这样在每次客户段调用都要进行非空判断,而且有时调用内置api还容易报错误,于是解 ...

  10. poj2749

    万变不离其宗 只要搞清楚题目的基本模型 搞清楚边是一种推导出的关系 搞清楚里面的逻辑关系 那就没什么难的了…… 二分+sat,没什么好说的 ; type node=record point,next: ...