我在使用SOAP的NSURLConnection
中遇到問題,它可以在所有應用程序類中正常工作,但在一個特定類中它不起作用,一旦我撥打[connection start];
該應用程序不會調用該調用後臺功能(委託功能),我敢肯定,我在主線程內運行,請求正確,我真的需要幫助,謝謝。 代碼:iOS NSURLConnection,未找到響應
if(!webData)
webData = [[NSMutableData alloc] init];
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<ActivateUser xmlns=\"http://tempuri.org/\">\n"
"<UserID>%@</UserID>\n"
"<MelarityNo>%@</MelarityNo>\n"
"<Phone>%@</Phone>\n"
"<Name>%@</Name>\n"
"<Personal>%@</Personal>\n"
"<Rank>%@</Rank>\n"
"</ActivateUser>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n", @"", self.policeManID, self.policeManPhoneNum, @"", self.policeManPersonalID,@""];
NSURL* url = [NSURL URLWithString:@"link here.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLen = [NSString stringWithFormat:@"%d", [soapMessage length]];
[req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://tempuri.org/ActivateUser" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLen forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
if(con)
con = nil;
con = [[NSURLConnection alloc] initWithRequest:req delegate:self];
[con start];
你在你的頭文件NSURLConnectionDelegate設置這些代表,NSURLConnectionDataDelegate> – shujatAli
和實施所有必要的回調? – shujatAli
不,但它在其他類中沒有它們就能正常工作! –