gpt4 book ai didi

ios - 得到错误:“线程1:SOAP请求期间EXC_BAD_ACCESS(Code = EXC_I386_GPFLT)

转载 作者:行者123 更新时间:2023-12-01 17:47:59 31 4
gpt4 key购买 nike

在我的 objective-c 代码中,我尝试访问SOAP Web服务,但由于错误而报错:“线程1:EXC_BAD_ACCESS(Code = 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];
}

最佳答案

将属性声明为strong而不是assign

@property (strong, nonatomic) NSString *encryptedUsername;
@property (strong, nonatomic) NSString *encryptedPassword;

关于ios - 得到错误:“线程1:SOAP请求期间EXC_BAD_ACCESS(Code = EXC_I386_GPFLT),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42021811/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com