首页 > 解决方案 > 任务.<0> HTTP 加载失败,0/0 字节(错误代码:-1200 [3:-9858])

问题描述

我在我的应用程序中使用上传图片的功能。应用程序使用 SOAP 请求将图像发送到服务器。最近我将网址从 http 设置为 https,我遇到了这个问题,

任务 .<0> HTTP 加载失败,0/0 字节(错误代码:-1200 [3:-9858])

NSURLConnection 完成错误 - 代码 -1200

我已经尝试了 info.plist 中的所有更改,但它不起作用。请你帮助我好吗?谢谢

标签: iosobjective-chttpsnsurlconnection

解决方案


好吧,看看这个...

if ([challenge.protectionSpace.authenticationMethod  
isEqualToString:NSURLAuthenticationMethodServerTrust])      
[challenge.sender useCredential:[NSURLCredential    
credentialForTrust:challenge.protectionSpace.serverTrust] 
forAuthenticationChallenge:challenge];

[challenge.sender   
continueWithoutCredentialForAuthenticationChallenge:challenge];

认为应该是

if ([challenge.protectionSpace.authenticationMethod  
isEqualToString:NSURLAuthenticationMethodServerTrust])      
[challenge.sender useCredential:[NSURLCredential    
credentialForTrust:challenge.protectionSpace.serverTrust] 
forAuthenticationChallenge:challenge];
else // you need to add an else here
[challenge.sender   
continueWithoutCredentialForAuthenticationChallenge:challenge];

编辑

另外,我看到您将 URL 指定为

https://pro-ap.com.au/Mobile/profilepic.asmx?

删除最后一个问号,因为它是请求的一部分,将在构建请求时自动附加。


推荐阅读