ios调用c#后台接口报文格式
- 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]; 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]);
}]; - [manager SOAP:@"/WebServices/WeatherWebService.asmx" constructingBodyWithBlock:^(NSMutableURLRequest *request) {
- [request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
- } 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);
- }];
ios调用c#后台接口报文格式的更多相关文章
- 原创:微信小程序调用PHP后台接口,解析纯html文本
---效果图片预览--- 1.微信js动态传参:wx.request({ url: 'https://m.****.com/index.php/Home/Xiaoxxf/activ ...
- angular-使用定时器调后台接口
今天写了一个功能,一个是在两个页面中每隔一秒就调用一个后台接口 首先,这个功能使用了JS里的定时器.JS计时器分为一次性计时器和间隔性触发计时器,此次每隔一秒要调用这个接口,使用的是间隔性触发计时器 ...
- c#代码 天气接口 一分钟搞懂你的博客为什么没人看 看完python这段爬虫代码,java流泪了c#沉默了 图片二进制转换与存入数据库相关 C#7.0--引用返回值和引用局部变量 JS直接调用C#后台方法(ajax调用) Linq To Json SqlServer 递归查询
天气预报的程序.程序并不难. 看到这个需求第一个想法就是只要找到合适天气预报接口一切都是小意思,说干就干,立马跟学生沟通价格. 不过谈报价的过程中,差点没让我一口老血喷键盘上,话说我们程序猿的人 ...
- thinkjs学习-this.assign传递数据和ajax调用后台接口
在页面加载时,就需要显示在页面上的数据,可以在后台使用this.assign赋值,在前台通过ejs等模板获取:用户点击按钮,或者触发某些事件和后台进行交互时,就需要用到ajax调用后台接口.本文通过一 ...
- Utils--前台调用后台接口工具类
Utils--前台调用后台接口工具类 package com.taotao.manage.httpclient; import java.io.IOException; import java.net ...
- js调用后台接口进行下载
js调用后台接口一定不能用ajax location.href=$$pageContextPath +'downfile/down.do?filname='+row.fileUrl;
- 小程序调用wx.chooseLocation接口的时候无法获取权限(ios)
ios手机小程序调用wx.chooseLocation接口的时候,获取权限的时候报authorize:fail:require permission desc这样子的错误,这是由于苹果的安全机制导致需 ...
- 微信小程序 带参调用后台接口 循环渲染页面 wx.request wx:for
test.js 文件里的onLoad function getarticles(p,order,mythis) { wx.request({ url: 'https://ganggouo.cn/ind ...
- 发送短信验证码及调用短信接口与C# 后台 post 发送
#region 调用短信接口 public ActionResult Mobile(string Tel)//调用接口 { Random rm = new Random(); int i; strin ...
随机推荐
- 2015年11月26日 Java基础系列(六)正则表达式Regex
package com.demo.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @autho ...
- [译] ASP.NET MVC 6 attribute routing – the [controller] and [action] tokens
原文:http://www.strathweb.com/2015/01/asp-net-mvc-6-attribute-routing-controller-action-tokens/ 当在Web ...
- codevs2171 棋盘覆盖
题目描述 Description 给出一张n*n(n<=100)的国际象棋棋盘,其中被删除了一些点,问可以使用多少1*2的多米诺骨牌进行掩盖. 输入描述 Input Description 第一 ...
- SGU 495. Kids and Prizes
水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...
- JAVA 笔记
一.Java基础以及面向对象编程1.float类型的数自动转换成double类型时,可能会出现前后不相等的情况,因为有些数不能够用有限的二进制位精确表示.2.右移>>右移,左边空出位以符号 ...
- Codeforces Round #336 Hamming Distance Sum
题目: http://codeforces.com/contest/608/problem/B 字符串a和字符串b进行比较,以题目中的第一个样例为例,我刚开始的想法是拿01与00.01.11.11从左 ...
- jquery常用
获取元素宽度 .innerWidth() // 包含padding .outerWidth() // 包含padding, border .outerWidth(true)//包含padding, b ...
- 最简单的Android教程之自定义控件
新建title.xml,完成布局 新建一个TitleLayout继承 LinearLayout. activity_main.xml中引用 Run your applicaiton , and try ...
- TP中手动加载类库
加载第三方类库,包括不符合命名规范和后缀的类库,以及没有使用 命名空间或者空间和路径不一致的类库.可手动加载. // 导入Org类库包 Library/Org/Util/Date.class.php类 ...
- Android_bug之Default Activity not found
在运行自己修改默认的MainActivety,运行自己的Mainactivety时,碰到这个问题Could not identify launch activity: Default Activity ...