1
A
回答
4
可能有兩個問題: -
1當前未接收到正確的數據,因爲你沒有給密碼&用戶名在委託
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
實現它像這是NSURLConnection的委託(如果你使用它)。
#define LOGIN @"RFC_ESERVICE"
#define PASSWORD @"[email protected]"
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
if ([challenge previousFailureCount] == 0)
{
NSURLCredential *credential = [NSURLCredential credentialWithUser:LOGIN
password:PASSWORD
persistence:NSURLCredentialPersistenceNone];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}
}
2如果您收到數據但無法解析它,請發佈代碼。 此外,XML似乎是一個WSDL,你想分析哪些信息?
3
這是你如何使用的NSXMLParser:
In your .h file declare :
NSMutableData *webPortFolio;
NSMutableString *soapResultsPortFolio;
NSURLConnection *conn;
//---xml parsing---
NSXMLParser *xmlParserPortFolio;
BOOL elementFoundPortFolio;
NSMutableURLRequest *req;
NSString *theXMLPortFolio;
NSString *strSoapMsg;
UIAlertView *alertView;
在您.m文件使用下面的代碼:
-(void)callURL
{
NSString *soapMsg = [NSString stringWithFormat:@"email=%@&pass=%@&type=activate",txt_UserName.text,txt_Password.text]; //Add your parameters here.
//---print it to the Debugger Console for verification---
NSString *str_url = [ NSString stringWithFormat:@"%@login",xmlWebservicesUrl]; //Your URL here
NSURL *url = [NSURL URLWithString:str_url];
req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMsg length]];
[req addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
//Your logic to call URL.
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn)
{
webPortFolio = [[NSMutableData data] retain];
}
}
And to handle the response you can use following functions :
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
}
-(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error
{
}
-(void) connectionDidFinishLoading:(NSURLConnection *) connection
{
}
//---when the start of an element is found---
-(void) parser:(NSXMLParser *) parser
didStartElement:(NSString *) elementName
namespaceURI:(NSString *) namespaceURI
qualifiedName:(NSString *) qName
attributes:(NSDictionary *) attributeDict
{
}
-(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string
{
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
{
NSLog(@"Parser error %@ ",[parseError description]);
}
//---when the end of element is found---
-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
}
1
NSString *[email protected]"https://ecservices.wasl.ae/sap/bc/srt/wsdl/bndg_514403C105C32C67E10000000AF00316/wsdl11/allinone/ws_policy/document?sap-client=100";
NSMutableURLRequest *theRequest=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlSt]];
NSString *authStr = [NSString stringWithFormat:@"RFC_ESERVICE:[email protected]"];
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodingWithLineLength:80]];
[theRequest setValue:authValue forHTTPHeaderField:@"Authorization"];
NSLog(@"Request is %@",theRequest);
[_webview loadRequest:theRequest];
相關問題
- 1. Swift JSON解析用戶名和密碼
- 2. 從需要用戶名和密碼的遠程URL解析JSON
- 3. 解析:無效的用戶名,密碼
- 4. iphone用戶名密碼MD5
- 5. 使用用戶名密碼認證和XML解析的HTTP
- 6. iPhone cookies存儲用戶名和密碼
- 7. UITableView中的用戶名,密碼? (iOS,iPhone)
- 8. 用戶名和密碼在URL
- 9. 使用URI :: URL從SFTP URL中提取用戶名和密碼
- 10. 當用戶名包含'@'字符時,javax.mail.URLName無法解析用戶名和密碼
- 11. 的用戶名和密碼
- 12. 解析備選方案以跟蹤用戶名和密碼?
- 13. 使用用戶名密碼保護URL
- 14. iPhone SDK:在代碼中存儲用戶名和密碼
- 15. 在iPhone中使用用戶名和密碼登錄表單
- 16. 如何解析具有特殊字符的用戶名或密碼的FTP URL?
- 17. 用戶名和密碼
- 18. Multyvac用戶名和密碼
- 19. phpmyadmin用戶名和密碼
- 20. 從UITextField獲取用戶名密碼iPhone
- 21. 測試iphone應用程序審查的用戶名和密碼
- 22. Java - 從配置文件加密/解密用戶名和密碼
- 23. 如何在我的iphone應用程序中保存用戶名和密碼iphone
- 24. 如何從node.js中的url讀取用戶名和密碼?
- 25. 如何從ASP.NET中的url獲取用戶名和密碼?
- 26. JDBC連接URL中的用戶名和密碼
- 27. URL編碼(發帖的用戶名和密碼)
- 28. Git中的用戶名和密碼
- 29. Python 3.6中的用戶名和密碼
- 30. 解析用戶密碼重置Swift iOS
你從你的服務器 – 2013-03-18 09:07:39
得到什麼類型的數據可以爲您詳細說明你的問題? – 2013-03-18 09:07:39
在獲取服務響應或解析響應時出現問題時,您是否遇到問題? – 2013-03-18 09:10:05