我在iOS中實現了SOAP服務。 我正在使用以下代碼發送請求。SOAP XML中的問題
NSString *sSOAPMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<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/\">"
"<soap:Body>"
"<CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\">"
"<Celsius>50</Celsius>"
"</CelsiusToFahrenheit>"
"</soap:Body>"
"</soap:Envelope>";
NSURL *sRequestURL = [NSURL URLWithString:@"http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest *myRequest = [NSMutableURLRequest requestWithURL:sRequestURL];
NSString *sMessageLength = [NSString stringWithFormat:@"%d", [sSOAPMessage length]];
[myRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[myRequest addValue: @"http://www.w3schools.com/webservices/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"];
[myRequest addValue: sMessageLength forHTTPHeaderField:@"Content-Length"];
[myRequest setHTTPMethod:@"POST"];
[myRequest setHTTPBody: [sSOAPMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:myRequest delegate:self];
if(theConnection) {
webData = [[NSMutableData data] retain];
}else {
NSLog(@"Some error occurred in Connection");
}
而且我得到以下回應。沒有得到任何值,即攝氏或華氏值作爲響應。
迴應在哪裏? – preetam
它將返回網頁。使用一些HTML標記和跨度 – Apoorv