I am developing an app using IOS 8 in which I am using SOAP service to save data to server.
Service works fine and getting response if my method name string length is less than 65535.
If my method name string length is greater than 65535, then I am not getting any response from server.
Here is the code.
-(void)fetchDataFromURL:(NSString *)finalURL withMethodName:(NSString *)methodName withType:(NSString *)methodType migrationCompletionHandler:(void(^)(BOOL resultValue, NSData *responseData, NSString *internetStatus, NSError * error))completionBlock
{
someActionHandler = completionBlock;
reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
//Web Service Call
if (internetStatus != NotReachable)
{
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<SOAP-ENV:Envelope \n"
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
"xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" \n"
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"> \n"
"<SOAP-ENV:Body> \n"
"%@\n"
"</SOAP-ENV:Body> \n"
"</SOAP-ENV:Envelope>",finalURL];
NSURL *url = [NSURL URLWithString:@"myURLString"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:25];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
[theRequest setValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
NSString *method=[NSString stringWithFormat:@"http://Namespace%@",methodName];
[theRequest setValue:method forHTTPHeaderField:@"Soapaction"];
[theRequest setValue:@"chunked" forHTTPHeaderField:@"transfer-coding"];
[theRequest setValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:methodType];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSError * error = nil;
NSURLResponse * response = nil;
NSData * data = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
if (error)
{
completionBlock(FALSE,nil,@"YES",error);
}
else
{
completionBlock(TRUE, data,@"YES",nil);
}
}
else
{
completionBlock(FALSE,nil, @"NO", nil);
}
}