Guest User

Untitled

a guest
Dec 13th, 2016
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "ViewController.h"
  2. //#import "AFNetworking.h"
  3.  
  4. @interface ViewController ()
  5.  
  6. @end
  7.  
  8. @implementation ViewController
  9.  
  10. - (void)viewDidLoad {
  11. [super viewDidLoad];
  12. // Do any additional setup after loading the view, typically from a nib.
  13. }
  14.  
  15.  
  16. - (void)didReceiveMemoryWarning {
  17. [super didReceiveMemoryWarning];
  18. // Dispose of any resources that can be recreated.
  19. }
  20.  
  21. - (IBAction)submitBtnPressed:(id)sender {
  22. NSString *sturl = [NSString stringWithFormat:@"http://servername/authentication/login"];
  23.  
  24. NSURL *url = [[NSURL alloc] initWithString:sturl];
  25.  
  26. NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
  27.  
  28. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  29. NSDictionary *parameters = @{@"userName": @"chanml",
  30. @"password": @"password"
  31. };
  32. [manager POST:sturl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject)
  33. {
  34. NSLog(@"JSON: %@", responseObject);
  35. }failure:^(AFHTTPRequestOperation operation, NSError error) {
  36. NSLog(@"Error: %@", error);
  37. }];
  38.  
  39. }
  40. @end
  41.  
  42. public interface Iauthentication
  43. {
  44. [OperationContract]
  45. void DoWork();
  46.  
  47.  
  48. [OperationContract]
  49. [WebInvoke(Method = "POST",
  50. RequestFormat = WebMessageFormat.Json,
  51. ResponseFormat = WebMessageFormat.Json,
  52. BodyStyle = WebMessageBodyStyle.Bare,
  53. UriTemplate = "login")]
  54. ////UriTemplate = "login?userName={userName}&password={password}")]
  55. ResponseData GetLoginData();
  56.  
  57.  
  58. //string GetLoginData(string userName, string password);
  59.  
  60.  
  61. }
  62.  
  63. [DataContract(Namespace = "http://tempuri.org")]
  64. public class RequestData
  65. {
  66. [DataMember]
  67. public string userName { get; set; }
  68.  
  69. [DataMember]
  70. public string password { get; set; }
  71. }
  72.  
  73. [DataContract]
  74. public class ResponseData
  75. {
  76. [DataMember]
  77. public string username { get; set; }
  78.  
  79. [DataMember]
  80. public string password { get; set; }
  81.  
  82. [DataMember]
  83. public string name { get; set; }
  84.  
  85. }
RAW Paste Data