Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:47:18+00:00 2026-06-14T12:47:18+00:00

On a web server is the following method: [WebMethod()] public static string login(string userName,

  • 0

On a web server is the following method:

[WebMethod()]
public static string login(string userName, string password)
{
    if (usernName == "test" && password == "test")
    {
         return "validated";
    }
    return "error";
}

I’m trying to connect to it with the following Objective C code:

NSString *post = [NSString stringWithFormat:@"userName="test"&password="test"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSString *serverURLString = @"http://myURL.aspx/login";
NSURL *serverURL = [NSURL URLWithString:serverURLString];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:serverURL];
[request setHTTPMethod:@"POST"];

[request addValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];

NSHTTPURLResponse *urlResponse = nil;
NSError *error = nil;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];

NSLog(@"response data = %@", responseData);

I got lost in ignorant newbie land and thought the last line would print out either “validated” or “error” in my Objective C console but it returns an integer (which I’m sure is obvious to those of you who have done this before =)).

Can anyone tell me how I would get to see the webMethod return value in my Objective C log?

-EDIT-
I’ve just noticed that I get an HTTP response status code of 200, regardless of whether I use the correct userName/password combination or not, which I’m guessing could also mean the issue lies elsewhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:47:19+00:00Added an answer on June 14, 2026 at 12:47 pm

    You can create an NSString using the NSData returned in the response. E.g.:

    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Within our web application we are using the following method of server communication XMLHttpRequest
I have the following method being called in a Java EE web application. public
I try to run jsf application in myeclipse using jboss web server and following
In the web.xml of my web app I have configured the server as following:
I have the following textbox server control in my web page: <asp:TextBox ID=txtZip runat=server
One of our products implements the following one-way web service structure: Server <--------------------- Middleware
Within a web form I have the following jQuery setup to call a method
I get the following error Web Service method name is not valid when i
Consider the following case: A web server is running a .NET app with <sessionState
In the following scenario: 1 Database 4 Web servers How do the Web servers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.