0
votes

I have some trouble getting a response using ASIHTTPRequest which is quite nerve-wrecking. I am sending a SOAP Request inside the POST-Body of an ASIHTTPRequest to a server. The Request is sending fine so far but the Response String is "(null)" according to the Console and the Length of the response Data is 0. However, when I send the SOAP-Body String, that I put in the Console using NSLog(); to the server with the Firefox Plugin "POSTER" I get the response that i want. And on the other hand, as soon if there'S an error in the SOAP-Request is get a response in ASIHTTPRequest. So far I'm completely out of ideas and it would be very kind if somebody got an idea to help.

Here'S my Code.

ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:myURL];
[request addRequestHeader:@"Content-Type" value:@"text/xml"];
NSLog(@"XML: %@",[carInsurance buildXMLString]); //Debug output
NSMutableData *theData = [[carInsurance buildXMLString] dataUsingEncoding:NSUTF8StringEncoding];
[request addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%d",[theData length]]];
[request setPostBody:theData];
[request setRequestMethod:@"POST"];
NSLog(@"Headers before: %@",[[request requestHeaders] description]); //Debug output
[request startSynchronous];
NSLog(@"Headers after: %@",[[request requestHeaders] description]);

For the more curious one here are my Debug headers.

2010-10-12 14:39:11.945 appname[12484:207] Headers before: { "Content-Length" = 1944; "Content-Type" = "text/xml"; }

1

1 Answers

1
votes

Install a tool like wireshark and use it to sniff the request and the response (using the iphone simulator).

Presuming the response is empty there too, sniff the request as sent by POSTER and compare that to the one sent by the iphone.

If it's still not obvious what's wrong add the wireshark "follow tcp stream" output into your question.