首页 新闻 赞助 找找看

ios 使用ASIHTTPRequest时遇到的小问题,求达人解释

0
悬赏园豆:20 [待解决问题]

//返回ASIHTTPRequest对象

-(ASIHTTPRequest*)ServiceRequestUrl:(NSString*)strMethod SoapMessage:(NSString*)soapMsg{

//请求发送到的路径

    NSURL * url = [NSURLURLWithString:@"http://192.168.123.132/eland/WebServices/WebService.asmx"];

 

    //NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

   ASIHTTPRequest *theRequest= [ASIHTTPRequestrequestWithURL:url];

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

 

    //以下对请求信息添加属性前四句是必有的,第五句是soap信息。

[theRequest addRequestHeader:@"Host" value:[url host]];

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

[theRequest addRequestHeader:@"Content-Length" value:msgLength];

    [theRequest addRequestHeader:@"SOAPAction"value:[NSStringstringWithFormat:@"http://tempuri.org/%@", strMethod]];

    [theRequest setRequestMethod:@"POST"];

//soap信息

    [theRequest appendPostData:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];

    //[theRequest setValidatesSecureCertificate:NO];

    [theRequest setTimeOutSeconds:60.0];

    [theRequest setDefaultResponseEncoding:NSUTF8StringEncoding];

return theRequest;

//return theRequest;

}

 

//在按钮点击下执行请求

-(IBAction)buttonServiceClick:(id)sender{

NSString *soapMsg=@"<?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><GetCircular xmlns=\"http://tempuri.org/\" ><guid>07122d99-0978-46e4-aacb-3aed0ff99cb5</guid><pwd>123456</pwd><GetCircular></soap:Body></soap:Envelope>";

 

ASIHTTPRequest *request=[selfServiceRequestUrl:@"GetCircular"SoapMessage:soapMsg];

[request setDelegate:self];

[request startAsynchronous];//异步请求

}

//实现协议

- (void)requestFinished:(ASIHTTPRequest *)request

{

NSString *responseString = [request responseString];

NSLog(@"%@",responseString);

}

 

- (void)requestFailed:(ASIHTTPRequest *)request

{

NSError *error = [request error];

NSLog(@"%@",[error description]);

}

 

 

===>点击按钮时,发生 怪异了,在控制台一直输出==》

错误的请求

 

求达人,我那里错了〜〜〜

ios
固执的等待的主页 固执的等待 | 初学一级 | 园豆:182
提问于:2012-10-28 14:25
< >
分享
所有回答(1)
0

你得statecode是多少,是不是url写错了

 
新年新气象 | 园豆:210 (菜鸟二级) | 2015-11-17 16:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册