iOS 调用wcf 接口遇到的错误

Lucifer_帅帅 发布于 2013/10/16 09:46
阅读 1K+
收藏 0

在我用iOS 平台去调用 wcf的接口时发现我调不到里面的方法 返回的也是 一个网页 试过很多但是不知道那里出错了希望大虾能帮小弟一下谢谢



NSString *soapMessage = [NSString stringWithFormat:

@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"

"<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/\">\n"

"<soap:Body>\n"

"<WebLogin xmlns=\"http://218.207.93.158/AndroidInterFace/GPS_Interface.svc"

                             "<json>[\"holin\",\"332211\"]</json>\n"

                             "<methodName>WebLogin</methodName>\n"

                             "<returnXml>1</returnXml>\n"

"</WebLogin>\n"

"</soap:Body>\n"

"</soap:Envelope>\n"

];

NSLog(soapMessage);

    

    //请求发送到的路径

NSURL *url = [NSURL URLWithString:@"http://218.207.93.158/AndroidInterFace/GPS_Interface.svc"];

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

    

    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

    [theRequest addValue: @"http://tempuri.org/IHttpVclInfo_Service/CommonWcfMethodByClientHttp" forHTTPHeaderField:@"SOAPAction"];

[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];

[theRequest setHTTPMethod:@"POST"];

[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];


    NSData *rst = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];

    

    

    

    NSString *rstStr = [[[NSString alloc] initWithData:rst encoding:NSUTF8StringEncoding] autorelease];

    NSLog(@"rstStr = %@",rstStr);

    

打印的信息

?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

  <head>

    <title>Service</title>

    <style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } .heading1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>

  </head>

  <body>

    <div id="content">

      <p class="heading1">Service</p>

      <p>Endpoint not found.</p>

    </div>

  </body>

</html>





加载中
0
魏兴隆
魏兴隆

你好,我想问下你的这个问题解决了吗?

魏兴隆
魏兴隆
回复 @Lucifer_帅帅 : 恩恩是的 现在后台直接返回给我的是html的 然后也是用get
Lucifer_帅帅
Lucifer_帅帅
点击此处输入评论
Lucifer_帅帅
Lucifer_帅帅
恩,改的后台属性,并且只能用get传值
0
Lucifer_帅帅
Lucifer_帅帅
http://mobile.51cto.com/iphone-258405.htm给你个参考,或者是在百度直接搜 iOS调用wcf服务
返回顶部
顶部