Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ViewController.h"
- //#import "AFNetworking.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)submitBtnPressed:(id)sender {
- NSString *sturl = [NSString stringWithFormat:@"http://servername/authentication/login"];
- NSURL *url = [[NSURL alloc] initWithString:sturl];
- NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
- AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
- NSDictionary *parameters = @{@"userName": @"chanml",
- @"password": @"password"
- };
- [manager POST:sturl parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject)
- {
- NSLog(@"JSON: %@", responseObject);
- }failure:^(AFHTTPRequestOperation operation, NSError error) {
- NSLog(@"Error: %@", error);
- }];
- }
- @end
- public interface Iauthentication
- {
- [OperationContract]
- void DoWork();
- [OperationContract]
- [WebInvoke(Method = "POST",
- RequestFormat = WebMessageFormat.Json,
- ResponseFormat = WebMessageFormat.Json,
- BodyStyle = WebMessageBodyStyle.Bare,
- UriTemplate = "login")]
- ////UriTemplate = "login?userName={userName}&password={password}")]
- ResponseData GetLoginData();
- //string GetLoginData(string userName, string password);
- }
- [DataContract(Namespace = "http://tempuri.org")]
- public class RequestData
- {
- [DataMember]
- public string userName { get; set; }
- [DataMember]
- public string password { get; set; }
- }
- [DataContract]
- public class ResponseData
- {
- [DataMember]
- public string username { get; set; }
- [DataMember]
- public string password { get; set; }
- [DataMember]
- public string name { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement