Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking with Web services in iPhone
    text
    copied!<p>I'm using SOAP in an iPhone app, and I got this error:</p> <pre><code>&lt;faultcode&gt;soap:Client&lt;/faultcode&gt;&lt;faultstring&gt;Server did not recognize the value of HTTP Header SOAPAction: http://tempuri.org/CelsiusToFahrenheit.&lt;/faultstring&gt;&lt;detail /&gt;&lt;/soap:Fault&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt; </code></pre> <p>This is my code:</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://tempuri.org/\"&gt;\n" "&lt;Celsius&gt;%@&lt;/Celsius&gt;\n" "&lt;/CelsiusToFahrenheit&gt;\n" "&lt;/soap:Body&gt;\n" "&lt;/soap:Envelope&gt;\n",txt1.text]; 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://tempuri.org/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]]; </code></pre> <p>Any help will be appreciated, thanks.</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