Reputation: 4905
I have a web service created through Eclipse. Created a web service method and wsdl for that class. I would like to know how can i access this web service api from my iOS client? For ex: my wsdl file is 'ReceiverClass.wsdl' and 'ReceiverClass.java class contains a method called 'RespondResult(..)'. I know about NSURLConnection, i'm asking how can i point to this url api?
Thank you!
Getsy.
Upvotes: 0
Views: 7133
Reputation: 2795
There is no easy solution, easiest one is to move away from SOAP.
Meanwhile you can try http://sudzc.com/ or you can write a simple wrapper yourself which will send and receive XML packets.
In example below, I observed the xml packets through "Poster" firefox plugin and made generic methods to make SOAP request. The biggest drawback is that I'm ignoring WSDL and I have to implement each method myself (unlike Java).
- (void) requestData:(NSString *) request withParameters:(NSDictionary*)parameters
soapAction:(NSString*)soapAction serviceName:(NSString *)url
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
NSString *packet = [self formatRequest:request WithParameters:parameters];
NSData *envelope = [packet dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
[request1 setHTTPMethod:@"POST"];
[request1 setHTTPBody:envelope];
[request1 setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
AFHTTPRequestOperation * operation = [[AFHTTPRequestOperationManager manager] HTTPRequestOperationWithRequest:request1 success:success failure:failure];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
[[NSOperationQueue mainQueue] addOperation:operation];
}
- (NSString*) formatRequest:(NSString*)request WithParameters:(NSDictionary *)parameters
{
NSMutableString *packet = [[NSMutableString alloc] init];
[packet appendString:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
"<soap12:Body>"];
[packet appendFormat:@"<%@ xmlns=\"http://tempuri.org/\">",request];
for (NSString *key in parameters) {
[packet appendFormat:@"<%@>%@</%@>",key,[parameters objectForKey:key],key];
}
[packet appendFormat:@"</%@>",request];
[packet appendString:@"</soap12:Body></soap12:Envelope>"];
return packet;
}
Upvotes: 1
Reputation: 2634
You can use this iPhone Web Services Client. Also can refer to these tutorials.
SOAP Based Web Services Made Easy On The iOS Platform
Upvotes: 1
Reputation: 5453
You'll need a SOAP framework. There's not one built into iOS, but here's one which was the first hit on Github: https://github.com/priore/SOAPEngine.
Upvotes: 1