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 { }
  • 相关阅读:
    HAOI2018 简要题解
    HAOI2017 简要题解
    BZOJ 5477: 星际穿越
    HAOI2016 简要题解
    C#oracle还原imp实例
    oracle备份imp命令大全
    C#oracle备份和还原
    win10安装CAD后出现致命错误
    Oracle 恢复数据后,数据库中中文变成问号解决方法
    CAD 安装时出现.net frameword 3.5安装不上的问题
  • 原文地址:https://www.cnblogs.com/HJQ2016/p/5903106.html
Copyright © 2011-2022 走看看