Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>i too new ,but i have sent some msg(soap xml) via http request .my sample code is... </p> <p><pre><code></p> <p>// get host address NSURL *url = [NSURL URLWithString:@"http://xyz.com"]; NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:url];</p> <p>// find msg length, here x is my msg NSString *msgLength = [NSString stringWithFormat:@"%d", [x length]];</p> <p>// specify type of msg which u have to send to the host(mine is xml) [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; // name space which optional one [theRequest addValue: @"http://mpack.h.org" forHTTPHeaderField:@"SOAPAction"];</p> <p>[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; //type of http method [theRequest setHTTPMethod:@"POST"]; // msg which is need to send to server [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];</p> <p>// establish connection to host NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];</p> <p>if( theConnection ) { webData = [[NSMutableData data] retain]; NSLog(@"Connecting....");</p> <p>} else { NSLog(@"theConnection is NULL");</p> <p>}</p> <p>}</p> <p>// delegate method for NSURLConnection -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"ERROR with theConenction %@",error); [connection release]; [webData release];</p> <p>} // u ll get response here -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE. Received Bytes: %d", [webData length]);</p> <p>} </pre></code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload