我想調用以下web service,但想知道如何傳遞用戶名和密碼並獲得響應。將用戶名和密碼傳遞到Web服務
回答
@interface ViewController()
{
NSURLConnection *clearSession;
NSMutableData *receivedData;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self clearsession];
}
-(void)clearsession
{
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"https://mybusiness.expressoft.eu/webserviceintegration/v1/myshop/MyShopDataService.svc/"]];
NSString *requestString = [NSString stringWithFormat:@"Username=karthik&Password=abcdesg",nil];
NSLog(@" RequestString for get card details: %@",requestString);
NSMutableData *requestData =[NSMutableData dataWithBytes:[requestString UTF8String] length: [requestString length]];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: requestData];
clearSession = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (clearSession) {
NSLog(@"data sent ");
} else
{
NSLog(@"Not sent");
}
[clearSession start];
}
-(void)connection:(NSConnection*)conn didReceiveResponse:(NSURLResponse *)response
{
if (receivedData == NULL)
{
receivedData = [[NSMutableData alloc] init];
}
[receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"Connection failed! Error - %@ %@",
[error localizedDescription],
[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
UIAlertView *customAlert = [[UIAlertView alloc]initWithTitle:@"No NetWork" message:@"Interet Connection is Lost" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[customAlert show];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if (connection==clearSession)
{
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:receivedData options: kNilOptions error:nil];
NSString *tmp=[[NSString alloc]initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"%@", tmp);
NSLog(@" parsing JSON of add checkout: %@", jsonDict);
}
}
試試這個如果u沒有答案的東西,我希望用U – 2014-11-01 13:50:03
使用的Web服務是WCF數據服務類型和使用的OData協議尋址和更新資源。 ACCES通過認證報頭實現,所述通信協議(端點結合)是HTTP請求(的WebHttpBinding) – user3189586 2014-11-03 06:03:08
,並且從每個頭的請求必須以「基本用戶:密碼」中的「授權」密鑰格式。對於測試,用戶名是abc和密碼abc。 – user3189586 2014-11-03 06:05:23
- 1. symfony web服務用戶名和密碼
- 2. 使用sc查詢將用戶名和密碼傳遞到遠程服務器
- 3. JQUERY AJAX - 如何將證書(用戶和密碼)傳遞給Sharepoint Web服務
- 4. 發送用戶名和密碼到Web服務
- 5. Silverlight:加密Web服務的用戶名和密碼
- 6. WCF:將用戶名和密碼傳遞給另一個服務(無Https)
- 7. 傳遞用戶憑據到Web服務
- 8. 使用Spring .NET將用戶名和密碼發送到.net Web服務
- 9. 在web服務調用中使用用戶名和密碼
- 10. ASP.Net和Jquery客戶端密碼傳遞到服務器端
- 11. 以編程方式將用戶名和密碼發送到Apache Web服務器
- 12. 如何從iPhone應用程序中將用戶名和密碼傳遞給Web服務?
- 13. 如何將用戶名傳遞給共享點的Web服務
- 14. 安全PHP的Web服務(用戶名和密碼)
- 15. WCF Web服務需要訪問用戶名和密碼信息
- 16. Android XML Web服務用戶名和密碼驗證
- 17. 將用戶名和密碼傳遞給WSO2 ESB代理/端點
- 18. 將用戶名和密碼傳遞給Sharepoint
- 19. Topshelf將用戶名和密碼傳遞給配置
- 20. Ant:將用戶名和密碼傳遞給exec
- 21. 將用戶名和密碼傳遞給CryptRetrieveTimeStamp函數
- 22. 將用戶名和密碼傳遞給svcutil.exe?
- 23. 如何通過在android中調用wcf web服務來驗證用戶名和密碼? &如何傳遞用戶名和密碼以及請求?
- 24. jquery ajax和safari傳遞用戶名/密碼時遇到問題
- 25. ASP.NET僅在第一次使用用戶名和密碼登錄到Web服務
- 26. 將數據傳遞到SOAP Web服務
- 27. 使用用戶名和密碼將C#發送給Cassandra服務
- 28. 如何從iPhone應用程序傳遞訪問Web服務的用戶名和密碼?
- 29. 將用戶名和密碼從JSF或JSP傳遞到Oracle報告
- 30. 如何將密碼和用戶名從servlet傳遞到其他安全
る新的iOS中,在之前你永遠與web服務工作 – 2014-11-01 06:28:08
可以u顯示烏爾完整的Web服務的名稱,什麼是通過鍵值 – 2014-11-01 06:29:16
是即時通訊與網絡服務但Web服務的新工作。我沒有這樣的憑據。 – user3189586 2014-11-01 06:32:10