Yomi198991 2014-05-16 03:26
浏览 3271

MKNetworkKit调用Web Service失败

本人新手,刚接触MKNetworkKit类库,尝试调用Web Service的Login方法,不知道为什么老是失败。模拟器刚打开的时候网络状态是ReachableViaWiFi,但是我一点登录按钮,状态就变成NotReachable,是我哪里写错了吗?可是我用Safari是能连上的,这是为什么呢?

  • (IBAction)Login:(id)sender {
    self.username = self.Login_name.text;
    self.pwd = self.password.text;

    MKNetworkKitTestAppDelegate *myDelegate = [[UIApplication sharedApplication] delegate];

    myDelegate.gs_employee_no = self.username;

    MKNetworkEngine engine = [[MKNetworkEngine alloc] initWithHostName:@"10.54.45.*:****" customHeaderFields:nil];

    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setValue:self.username forKey:@"emp_no"];
    [dic setValue:self.pwd forKey:@"password"];

    MKNetworkOperation *op = [engine operationWithPath:@"Service.asmx" params:dic httpMethod:@"POST"];

    [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
    id json = [completedOperation responseString]; //有现成的返回json方法可直接调用
    //NSString *rs = (NSString *)json;
    NSDictionary *person = (NSDictionary *)json;

    NSString *name = [person objectForKey:@"userNmae"];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"欢迎!"
                                                    message:name
                                                   delegate:nil
                                          cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alert show];
    alert=nil;
    name=nil;
    

    }errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示!"
                                                    message:@"Web Service失败"
                                                   delegate:nil
                                          cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alert show];
    alert=nil;
    

    }];

    [engine enqueueOperation:op];
    }

下面是报错信息

2014-05-14 17:06:58.281 MKNetworkKitTest[1921:60b] -[MKNetworkEngine reachabilityChanged:] [Line 211] Server [10.54.45.**:****] is not reachable
2014-05-14 17:06:58.564 MKNetworkKitTest[1921:60b] -[MKNetworkOperation operationFailedWithError:] [Line 1347] Wednesday, May 14, 2014 at 5:06:58 PM China Standard Time

Request

curl -X POST -H "Accept-Language: en, fr, de, zh-Hans, zh-Hant, ja, nl, it, es, ko, pt, pt-PT, da, fi, nb, sv, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us" -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" "http://10.54.45.**:****/Service.asmx" -d "emp_no=0983" -d "password=abc.123"

Response

http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="soap:Receiverhttp://www.w3.org/2001/XMLSchema">soap:Receiver xml:lang="zh-CHS">服务器无法处理请求。 ---> 根级别上的数据无效。 第 1 行,位置 1。
, [The operation couldn’t be completed. (NSURLErrorDomain error 500.)]
2014-05-14 17:09:48.594 MKNetworkKitTest[1921:60b] -[MKNetworkOperation operationFailedWithError:] [Line 1355] State: 0

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮