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 8894079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:24:28+00:00 2026-06-14T23:24:28+00:00

When trying to connect to the following web method, Request format is invalid is

  • 0

When trying to connect to the following web method, “Request format is invalid” is returned:

public string myWebMethod(string test)
{
    return "connected";
}

This is the objective C code:

NSString *seshID = @"test-session";       
NSString *post = [NSString stringWithFormat:@"test=%@", seshID];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSString *comparisonURLString = SERVER_COMPARE_URL_STRING;
NSURL *comparisonURL = [NSURL URLWithString: comparisonURLString];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:comparisonURL];

[request setHTTPMethod:@"POST"];
[request addValue:postLength forHTTPHeaderField:@"Content-Length"];

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

NSString *response = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];    
NSLog(response);

However, if I alter the web method so that it takes no parameters:

public string myWebMethod()

And change the corresponding line in my obj-c code to:

NSString *post = [NSString stringWithFormat:@""];

It works, with the response:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">connected</string>

Can anyone explain why the latter seems to work but the former doesn’t? Thanks.

  • 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-14T23:24:29+00:00Added an answer on June 14, 2026 at 11:24 pm

    I’ve got a similar problem between JAVA WebMethod and C#. The problem was resolved by creating a class string1 inherant from SoapHeader and containing a string[].

    Then for your example, you can try this

    public string myWebMethod(string[] test)
    {
        return "connected";
    }
    

    or

    public string myWebMethod(char[] test)
    {
        return "connected";
    }
    

    You can check too with Fiddler what kind of data is really passed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a web server is the following method: [WebMethod()] public static string login(string userName,
I'm trying to connect and use a web service method. I'm getting the following
I am trying to connect to an mdf file using the following connection string:
When trying to connect to a web service using the following $client = new
I get the following error message when trying to connect a web app running
I'm getting the following error when trying to connect to a WCF web service:
I'm trying to connect to google documents (following Marco Cantu's excellent REST example) but
I am trying to connect to a sql database with the following code line
i get this following error when i am trying to connect my localhost mysql
I am trying to connect to FBJS bridge. It keeps giving me the following

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.