开发者

Alternative way for SOAP connection from Iphone?

I need to connect to my SOAP web service from IPhone, I tried the approach below and it worked:

NSURL *url = [NSURL URLWithString:@"http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url] 
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addV开发者_如何转开发alue: @"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");
}

this way I cen get response from Service, First I need to create some classes, then I need to parse this XML and fill my data objects with it. My questions is:

What is wrong with this method? Becase there are libraries like WSDL2ObjC which creates code from my wsdl, or cSOAP which is a client/server SOAP library.

Is the only point of using a SOAP library is that I dont need to write the classes that my XML will be parsed into? with my aprroach above it only seems like after parsing the xml everything will be ok, or I am missing something?

For why dont use WSDL2Objc, please see my question about it here There is no documentation!


  • Acces SOAP from iOS : How to access SOAP services from iPhone

  • Greate tutorial : http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜