在我的目標C代碼中,我嘗試訪問SOAP Web服務,但得到了錯誤:「線程1:EXC_BAD_ACCESS(代碼= EXC_I386_GPFLT) 「近以下行。在SOAP請求中線程1:EXC_BAD_ACCESS(代碼= EXC_I386_GPFLT)
NSString *httpBodySoapMsg = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"......
"</x:Envelope>\n", _encryptedUsername,_encryptedPassword, nonce, digest];
下面是我完整的代碼。
#pragma mark - login request method
- (void)sendValidateEmailRequest {
NSString *nonce = [NSString stringWithFormat:@"%ld", (long)(NSTimeInterval)([[NSDate date] timeIntervalSince1970])];
NSString *digest = [Utils sha1:[NSString stringWithFormat:@"%@%@%@", _textUsername.text, nonce, _textPassword]]; // input is forsha
NSString *httpBodySoapMsg = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<x:Envelope xmlns:x=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:mob=\"https://billing.eukhost.com/webservices/mobile_service_new?wsdl\">\n"
"<x:Header/>\n"
"<x:Body>\n"
"<mob:validate_email>\n"
"<mob:email>%@</mob:email>\n"
"<mob:password>%@</mob:password>\n"
"<mob:nonce>%@</mob:nonce>\n"
"<mob:digest>%@</mob:digest>\n"
"</mob:validate_email>\n"
"</x:Body>\n"
"</x:Envelope>\n", _encryptedUsername, _encryptedPassword, nonce, digest];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:DEMO_URL]];
[urlRequest setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[urlRequest setValue:[NSString stringWithFormat:@"%@%@", DEMO_URL, VALIDATE_EMAIL] forHTTPHeaderField:@"SOAPAction"];
[urlRequest setValue:@"Basic YjBlMDc2ZjAxZjFjZjAyODc6ODQ0NzI0ZGMyYjMwNWM4MzA=" forHTTPHeaderField:@"Authorization"];
[urlRequest setValue:_encryptedUsername forHTTPHeaderField:@"PHP_AUTH_USER"];
[urlRequest setValue:_encryptedPassword forHTTPHeaderField:@"PHP_AUTH_PW"];
NSString* deviceId = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; // IOS 6+
[urlRequest setValue:deviceId forHTTPHeaderField:@"PHP_AUTH_DEVICE"];
// @"96c6754c9dc3b654517c5"
NSString *msgLength = [NSString stringWithFormat:@"%ld", (long)(httpBodySoapMsg.length)];
[urlRequest setValue:msgLength forHTTPHeaderField:@"Content-Length"];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[httpBodySoapMsg dataUsingEncoding:NSUTF8StringEncoding]];
RestApi *restApi = [RestApi sharedManager];
restApi.delegate = self;
[restApi httpRequest:urlRequest withResponseId:VALIDATE_EMAIL_ID];
}
在哪條線上你有這個錯誤? 「httpBodySoapMsg參數附近」根本不清楚 –
@Anton Malmygin - 請檢查更新 – appleBoy21
您是否嘗試在此行上設置斷點並檢查_encryptedUsername,_encryptedPassword,nonce,摘要的值? –