我正在學習iPhone中的解析,當我在尋找教程時,我開始對SOAP和REST服務瞭解很少。iPhone中的SOAP和REST服務
現在我想學習SOAP和REST服務。
有沒有人有SOAP和REST的理論知識? 有沒有簡單的教程可用於初學者?
非常感謝。
我正在學習iPhone中的解析,當我在尋找教程時,我開始對SOAP和REST服務瞭解很少。iPhone中的SOAP和REST服務
現在我想學習SOAP和REST服務。
有沒有人有SOAP和REST的理論知識? 有沒有簡單的教程可用於初學者?
非常感謝。
看到這些鏈接,非常久遠的兩個
http://www.ajaxonomy.com/2008/xml/web-services-part-1-soap-vs-rest
http://greatgandhi.wordpress.com/2010/06/16/soap-vs-rest-%E2%80%93-the-best-webservice/
比較210非常感謝,,,這些鏈接很很多信息..... –
u'r歡迎4有史以來 – Saad
SOAP指南
http://sudzc.com/
REST指南
http://stackoverflow.com/questions/630306/iphone-rest-client
SOAP Web服務
-(IBAction) read_data
{
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<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/\">\n"
"<soap:Body>\n"
"<CelsiusToFahrenheit xmlns=\"http://tempuri.org/\">n"
"<Celsius>%@</Celsius>n"
"</CelsiusToFahrenheit>n"
"</soap:Body>\n"
"</soap:Envelope>\n",name.text
];
NSLog(@"soap Message= %@",soapMessage);
NSURL *url = [NSURL URLWithString:@"your URL "];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}
-(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");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(@"theXML %@",theXML); // Here is your received Value from url
[theXML release];
}
這裏的例子RESTful WebService
http://en.wikipedia.org/wiki/Web_service –