zoukankan      html  css  js  c++  java
  • 第三十六篇、webService

    在很多的情况下,我们会常常遇到webservive写的接口,往往这种情况下,我们就需要拼接一段报文去与服务器对接

    首先要明白webService的工作原理,,,(http://www.cnblogs.com/Jessy/p/3528341.html) //假如在这开始请求 NSString *webServiceBodyStr = [NSString stringWithFormat: @"<Jsjy_yjy xmlns="http://xxxxx.com/webservice/">" "<name>wanger</name>" "<pagenow>1</pagenow>" "<pagesize>20</pagesize>" "</Jsjy_yjy>"];//这里是参数 NSString *webServiceStr = [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> " "%@ " "</soap:Body> " "</soap:Envelope>", webServiceBodyStr];//webService头 NSString *SOAPActionStr = [NSString stringWithFormat:@"http://xxx.com/webservice/%@", @"Jsjy_yjy"];//SOAPAction NSURL *url = [NSURL URLWithString:@"http://xxxx/key/MurpjsjyService.asmx"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%ld", webServiceStr.length]; [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-type"]; [theRequest addValue:SOAPActionStr forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:[webServiceStr dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConn) { }else { }
  • 相关阅读:
    动软代码生成器 修改配置
    显示转换explicit和隐式转换implicit
    Memcache学习整理
    SQL2008-分页显示3种方法
    SQL2008-表对表直接复制数据
    SQL2008-删除时间字段重复的方法
    SQL2008-中不想插入从复记录
    SQL2008-c:PROGRA~1COMMON~1SystemOLEDB~1oledb32.dll出错找不到指定的模块
    ACCESS-如何多数据库查询(跨库查询)
    ACCESS-字符函数
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5903106.html
Copyright © 2011-2022 走看看