问:

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. 板级支持包(BSP)

    板级支持包(BSP)是介于主板硬件和操作系统中驱动层程序之间的一层,一般认为它属于操作系统一部分,主要是实现对操作系统的支持,为上层的驱动程序提供访问硬件设备寄存器的函数包,使之能够更好的运行于硬件主 ...

  2. QT中的字符串处理函数

    Fn 1 : arg 这个函数的具体声明不写了,它有20个重载,典型的示例代码如下: 1: #include <QtCore/QCoreApplication> 2: #include & ...

  3. AVPicture、AVFrame和AVPacket

    http://blog.csdn.net/ym012/article/details/6540065 从定义上可知,AVPicture是AVFrame的一个子集,他们都是数据流在编解过程中用来保存数据 ...

  4. spring+mybatis 框架搭建

    注意<!-- 中间的字要保持与左右留出一个空格,否则会报错说出现两杠线 --> 1.导入jar包 aopalliance-1.0.jarasm-3.3.1.jarcglib-2.2.2.j ...

  5. VC 为静态控件添加事件(修改ID号以后添加事件)

    操作系统:Windows 7软件环境:Visual C++ 2008 SP1本次目的:为静态控件添加事件,如:STATIC.Picture Control等等 有时候我们找到一个图片,为对话框背景添加 ...

  6. div+css实现导航示意箭头

    1.Div的宽高为100 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <h ...

  7. 【HDOJ】4210 Su-domino-ku

    DLX.在模板的基础上增加一个FILL属性,略修改即可. /* 4210 */ #include <iostream> #include <string> #include & ...

  8. Android开发之异步消息处理机制AsyncTask

    转自:Android AsyncTask完全解析,带你从源码的角度彻底理解 另外一篇比较详细的博文:http://blog.csdn.net/liuhe688/article/details/6532 ...

  9. 生成Excel錯誤 遠端程序呼叫失敗。 (發生例外狀況於 HRESULT: 0x800706BE)

    错误信息:详细信息:检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005.网上找到 ...

  10. c#基础这些你都看过吗?(一)-----仅供初学者使用

    1.注释(不写注释是流氓,名字瞎起是扯淡)‘///’一般用于注释函数,注释类.2.快捷键ctrl+k+d(有语法错误无法进行对齐)ctrl+j(快速弹出只能提示)shift+end,shift+hom ...