• 请求webservice接口的某方法数据


    NSURL *url = [NSURL URLWithString:@"http://xxx.xxx.com/xxx/xxxxWS?wsdl"];
        NSString *soapMsg=[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/" xmlns:ns1="空间">"
                           "<soap:Body>"
                           "<ns1:某方法>"
                           "<strUsername>%@</strUsername>"
                           "<strPassword>%@</strPassword>"
                           "<strAGName>%@</strAGName>"
                           "<OperatorName>%@</OperatorName>"
                           "<OperatorPwd>%@</OperatorPwd>"
                           "</ns1:某方法>"
                           "</soap:Body>"
                           "</soap:Envelope>", @"", @"", @"", @"", @""
                           ];
        
        NSString *space=@"空间";
        NSString *methodname=@"某方法";
        NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
        NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMsg length]];
        NSString *soapAction=[NSString stringWithFormat:@"%@%@",space,methodname];
        //头部设置
        NSDictionary *headField=[NSDictionary dictionaryWithObjectsAndKeys:[url host],@"Host",
                                 @"text/xml; charset=utf-8",@"Content-Type",
                                 msgLength,@"Content-Length",
                                 soapAction,@"SOAPAction",nil];
        [request setAllHTTPHeaderFields:headField];
        //超时设置
        [request setTimeoutInterval: 30 ];
        //访问方式
        [request setHTTPMethod:@"POST"];
        //body内容
        [request setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
  • 相关阅读:
    分享一下用终端的命令来恢复丢失的硬盘分区表 (转)
    Smart Link
    underrun || overrun
    mtr命令详解诊断网络路由
    tracert traceroute
    OE1、OE2、ON1、ON2路由有什么区别?
    GRE tunnel 2
    【SAP HANA】新建账户和数据库(2)
    【SAP HANA】SAP HANA开篇(1)
    入职一周
  • 原文地址:https://www.cnblogs.com/jingdizhiwa/p/5607339.html
Copyright © 2020-2023  润新知