简体   繁体   English

iPhone中的SOAP和REST服务

[英]SOAP and REST Services in iPhone

I am learning parsing in iPhone, When i was searching for the tutorials, i came to know very little bit about SOAP and REST services. 我正在学习iPhone中的解析,当我在寻找教程时,我对SOAP和REST服务了解得很少。

Now i wanted to learn SOAP and REST services. 现在,我想学习SOAP和REST服务。

Do any one have theoretical knowledge of SOAP and REST? 是否有人具有SOAP和REST的理论知识? Is there any simple tutorial available for the beginners? 有没有适合初学者的简单教程?

Thanks a lot in advance. 非常感谢提前。

SOAP GUIDE SOAP指南

http://sudzc.com/

REST GUIDE 休息指南

http://stackoverflow.com/questions/630306/iphone-rest-client

SOAP Web Service 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];
 }  

Here is the Example of RESTful WebService 这是RESTful WebService的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM