Click here to Skip to main content
15,609,235 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When iOS is consuming this WCF, it replies with 400 bad request. When they are consuming it without parameter (just calling the method without input parameters), it's OK. I think there may be some parameter type issue.

What could the issue be?

The iOS code, which is consuming my WCF is:

#import "ViewController.h"
//#import "AFNetworking.h"

@interface ViewController ()


@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);


The WCF code is:

public interface Iauthentication
void DoWork();

[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 = "")]
public class RequestData
public string userName { get; set; }

public string password { get; set; }

public class ResponseData
public string username { get; set; }

public string password { get; set; }

public string name { get; set; }

Updated 7-Oct-15 18:55pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900