Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>//Try This One It Returns integer value</p> <pre><code>NSString *soapFormat = [NSString stringWithFormat:@"&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n" "&lt;soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;\n" "&lt;soap:Body&gt;\n" "&lt;CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\"&gt;\n" "&lt;Celsius&gt;%@&lt;/Celsius&gt;\n" "&lt;/CelsiusToFahrenheit&gt;\n" "&lt;/soap:Body&gt;\n" "&lt;/soap:Envelope&gt;\n",@"50"]; NSURL *locationOfWebService = [NSURL URLWithString:@"http://www.w3schools.com/webservices/tempconvert.asmx"]; NSLog(@"web url = %@",locationOfWebService); NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService]; NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]]; [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:@"http://www.w3schools.com/webservices/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; //the below encoding is used to send data over the net [theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]]; NSURLResponse *response; NSData *data_reply; NSError *err; data_reply = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&amp;response error:&amp;err]; NSString *aStr = [[NSString alloc] initWithData:data_reply encoding:NSASCIIStringEncoding]; NSLog(@"aStr:%@",aStr); </code></pre> <p>O/P:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;CelsiusToFahrenheitResponse xmlns="http://www.w3schools.com/webservices/"&gt;&lt;CelsiusToFahrenheitResult&gt;122&lt;/CelsiusToFahrenheitResult&gt;&lt;/CelsiusToFahrenheitResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt; check this answer it returns 122 integer value....... </code></pre>
 

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