Send parameters to a web service.

Posted by Alejandra Meraz on Stack Overflow See other posts from Stack Overflow or by Alejandra Meraz
Published on 2010-04-05T20:35:08Z Indexed on 2010/04/06 3:43 UTC
Read the original article Hit count: 374

Before I start: I'm programming for Iphone, using objective C.

I have already implemented a call to a web service function using NSURLRequest and NSURLConnection. The function then returns a XML with the info I need.

The code is as follows:

NSURL *url = [NSURL URLWithString:@"http://myWebService/function"];
NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url];
NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

i also implemented the methods

  • didRecieveResponse
  • didRecieveAuthenticationChallenge
  • didRecievedData
  • didFailWithError
  • connectionDidFinishLoading.

And it works perfectly.

Now I need to send 2 parameters to the function: "location" and "module".
I tried using the following modification:

NSMutableURLRequest theRequest   = [[NSMutableURLRequest alloc] initWithURL:url];
[theRequest setValue:@"USA" forHTTPHeaderField:@"location"];
[theRequest setValue:@"DEVELOPMENT" forHTTPHeaderField:@"module"];
NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

But it doesn't seem to work. I'm doing something wrong? is there a way to know if I'm using the wrong names for the parameters (as maybe it is "Location" or "LOCATION" or it doesn't matter?)? or a way to know which parameters is the function waiting for...

Extra info:
I don't have access to the source of the web service so I can't modify it. But I can access the WSDL. The person who made the function say is all there... but I can't make any sense of it >.<

Any help would be appreciated. :)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c