Ios 将用户名和密码传递给Web服务

Ios 将用户名和密码传递给Web服务,ios,objective-c,iphone,ios7,Ios,Objective C,Iphone,Ios7,我想呼叫以下人员,但想知道如何传递用户名和密码并获得响应。r您在iOS中是新的,在您从未使用web服务之前,您可以显示您的完整web服务名称以及pass的关键值是什么是我是新的。我使用web服务,但该web服务没有这样的凭据。这是URL这是问题中已经给出的u,我需要关键值和u,其中服务器表示.php或.net或.soaptry。如果你没有得到答案,我希望使用的web服务是WCF数据服务类型,并使用OData协议寻址和更新资源。访问通过身份验证标头实现,通信协议(端点绑定)为HTTP请求(webH

我想呼叫以下人员,但想知道如何传递用户名和密码并获得响应。

r您在iOS中是新的,在您从未使用web服务之前,您可以显示您的完整web服务名称以及pass的关键值是什么是我是新的。我使用web服务,但该web服务没有这样的凭据。这是URL这是问题中已经给出的u,我需要关键值和u,其中服务器表示.php或.net或.soaptry。如果你没有得到答案,我希望使用的web服务是WCF数据服务类型,并使用OData协议寻址和更新资源。访问通过身份验证标头实现,通信协议(端点绑定)为HTTP请求(webHttpBinding),每个标头请求的“授权”密钥必须为“基本用户:密码”格式。对于测试,用户名是abc,密码是abc。如果更改您的web服务是全局的,我会在这里尝试,否则我没有选择mauser name和Password不是abc,我可以单独向您提供。
@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);


}

}