1

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);
    }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Aabasaheb Deshpande
  • 399
  • 1
  • 3
  • 13
  • 1
    `length` property if a `NSString` returns a `NSUInteger` which is a `unsigned long NSUInteger`. On 32-bits apps, it's a 32-bits unsigned integer, while on 64-bits apps, it's a 64-bit unsigned integer. Your value "65535" is the max value with a 16-bits unsigned integer. Do you see an error when it's too long? Could be an issue on the server. Maybe a hint there: http://stackoverflow.com/questions/12951878/nsurlconnection-unable-to-http-post-large-file – Larme Sep 28 '15 at 08:20
  • Thanks, issue was from server side. resolved issue by increasing buffer size from server. – Aabasaheb Deshpande Oct 07 '15 at 04:50

0 Answers0