不帶參數的方法會按預期提供正確的結果。而webservice的方法需要很少的參數返回沒有相關的結果,而不是顯示消息。iPhone中的SOAP Xml問題
im使用以下代碼:
NSString *post =[[NSString alloc] initWithFormat:@"param1=%@¶m2=%@¶m3=%@¶m4=%@&pageSize=%@&pageNo=%@",@"",@"81",@"1",@"",@"40",@"1"];
NSURL *url = [NSURL URLWithString:@"www.someurlxyz.com"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
soapMsg = [soapMsg stringByAppendingString:post];
NSLog(@"value of soap is %@",soapMsg);
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
//postData =[postData stringByAppendingString:];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://www.someurlxyz.com/Search/Methodname?" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
[post release];
消息(其被退回被以下)。 服務器無法識別HTTP Header SOAPAction的值:http://www.someurlxyz.com/Search/Methodname?
請不要在問題標題中表達緊迫感。 – 2011-02-25 13:26:39