2
votes

again i am trying with soap method, but this time i downloaded the charles and observe the request that i create from my code. Chales showing "failed to parse data(org.xml.sax.saxparser exception:content is not allowed in prolog)"

here is my code:

   NSString *soapMsg = [[NSString alloc] initWithFormat:@"\n"
                         "\n"
                         ""
                         "\n"
                         "%@\n"
                         "%@\n"                                                                                                              
                         "%@\n"
                         "%@\n"
                         "\n"
                         "\n"
                         "\n",str1,str2,str3,str4];                       
        NSLog(soapMsg);

    NSURL *url = [NSURL URLWithString:@"http://192.168.0.218:84/WebServiceCustomerByAmit/Service.asmx?op=InsertCustomerInformation"];
    NSLog(@"url. . . .%@", url);
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];    
    NSLog(@"req....%@", req); 
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];


    NSLog(@"msgLength. . .%@", msgLength);
    [req addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [req addValue: @"http://tempuri.org/InsertCustomerInformation" forHTTPHeaderField:@"SOAPAction"];
    [req addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [req setHTTPMethod:@"POST"];
    [req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"req....%@", req);
    NSError *error;
    NSURLResponse *response;
    //NSData *urlData=[NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];


     NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];

     if( theConnection )
     {
         //webData = [[NSMutableData data] retain];
         NSLog(@"theConnection is OK");
     }
     else
     {
         NSLog(@"theConnection is NULL");
     }





     if(!response){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"Failed to Connect to the Internet" delegate:self  cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

    else{
        UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Connection Successful" message:@"Connected to the Internet" delegate:self  cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert1 show];
        [alert1 release];

    }
} 


help!! thanks in advance!!

1
try remove op=InsertsCustomerInformation in the end of the SOAP URL, if you make a breakpoint in the service Constructor do you receive any signal?Ahmad Kayyali
Please copy and paste your code and xml into the question. Not images of them.user467105
@anna: actually code is having tags and not displaying properly. Thats why i attached images.Ketan Shinde
Treat it as "code" in the SO editor. The tags will appear fine.user467105
You build a request, where do you actually send anything, and what response do you get from the service?Jordan

1 Answers

1
votes

You are asking how to include ASIHTTPRequest in your project, right? Copy and paste ASIHTTPRequest's folder in your project's folder and add this in your code:

#import "ASIHTTPRequest.h"

Note that ASIHTTPRequest is an external library and not part of the iOS SDK.