SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.
Install / Use
/learn @priore/SOAPEngineREADME
SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and Apple TV app.
With this Framework you can create iPhone, iPad, Mac OS X and AppleTv apps that supports SOAP Client Protocol. This framework able executes methods at remote web services with SOAP standard protocol.
Features
- Support both 2001 (v1.1) and 2003 (v1.2) XML schema.
- Support array, array of structs, dictionary and sets.
- Support for user-defined object with serialization of complex data types and array of complex data types, even embedded multilevel structures.
- Supports ASMX Services, WCF Services (SVC) and now also the WSDL definitions.
- Supports Basic, Digest and NTLM Authentication, WS-Security, Client side Certificate and custom security header.
- Supports iOS Social Account to send OAuth2.0 token on the request.
- AES256 or 3DES Encrypt/Decrypt data without SSL security.
- An example of service and how to use it is included in source code.
Requirements for iOS
- iOS 8.0 and later
- Xcode 8.0 or later
- Security.framework
- Accounts.framework
- Foundation.framework
- UIKit.framework
- libxml2.dylib
Requirements for Mac OS X
- OS X 10.9 and later
- Xcode 8.0 or later
- Security.framework
- Accounts.framework
- Foundation.framework
- AppKit.framework
- Cocoa.framework
- libxml2.dylib
Requirements for Apple TV
- iOS 9.0 and later
- Xcode 8.0 or later
- Security.framework
- Foundation.framework
- UIKit.framework
- libxml2.dylib
Limitations
- for WCF services, only supports basic http bindings (basicHttpBinding).
- in Mac OS X unsupported image objects, instead you can use the NSData.
Known issues
-
Swift 4: the library is currently written in Objective-C and when you import the swift library you will get build errors like this
The use of Swift 3 @objc inference in Swift 4 mode is deprecated.For silent this warning is need sets
Swift 3 @objc Inferenceto default value in the the Build settings of target. but It's not all; the classes used to create requests must be declared with@objcMembersandNSObject, eg:class MyClass { ... } let param = MyClass() // ... // ... let soap = SOAPEngine() soap.setValue(param, forKey: "myKey") // ... // ...the declaration of MyClass must become :
@objcMembers class MyClass: NSObject { ... }
Security for Xcode 8.x or later
From the new Xcode 8 is required an additional setting for the apps, if this setting does not exist you will see a log message like this:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
To resolve this, add few keys in info.plist, the steps are:
- Open
info.plistfile of your project. - Add a Key called
NSAppTransportSecurityas a Dictionary. - Add a Subkey called
NSAllowsArbitraryLoadsas Boolean and set its value to YES as like following image.

ref link: http://stackoverflow.com/a/32631185/4069848
Migrate from 1.43 to 1.44
This version (1.44) was designed to optimize performance and remove older functionality.
There are no substantial differences but no longer uses delegates with xml in string format, now just uses the format of the data already parsed and converted into a dictionary.
The peculiarity of this version is now works completely in secondary tasks, so all delegates, notifications and closures, now are generated in secondary tasks. If in these delegates are necessary to update the UI, will be necessary to perform the update in a main thread, in this case will be necessary to use dispatch_async(dispatch_get_main_queue(), ^{...}) for Objective-C language, or DispatchQueue.main.async {...} for Swift language.
If no data is retrieved, after a request, an error may be generated with the following message : "SOAPEngine no valid response, try again with actionNamespaceSlash set to YES or/and responseHeader set to YES".
How to use
with Delegates :
#import "SOAPEngine.h"
// standard soap service (.asmx)
SOAPEngine *soap = [[SOAPEngine alloc] init];
soap.userAgent = @"SOAPEngine";
soap.delegate = self; // use SOAPEngineDelegate
// each single value
[soap setValue:@"my-value1" forKey:@"Param1"];
[soap setIntegerValue:1234 forKey:@"Param2"];
// service url without ?WSDL, and you can search the soapAction in the WSDL
[soap requestURL:@"http://www.my-web.com/my-service.asmx"
soapAction:@"http://www.my-web.com/My-Method-name"];
#pragma mark - SOAPEngine Delegates
- (void)soapEngine:(SOAPEngine *)soapEngine didFinishLoadingWithDictionary:(NSDictionary *)dict data:(NSData *)data {
// read data from a dataset table
NSArray *list = [dict valueForKeyPath:@"NewDataSet.Table"];
}
with Block programming :
#import "SOAPEngine.h"
// TODO: your user object
MyClass myObject = [[MyClass alloc] init];
SOAPEngine *soap = [[SOAPEngine alloc] init];
soap.userAgent = @"SOAPEngine";
soap.version = VERSION_WCF_1_1; // WCF service (.svc)
// service url without ?WSDL, and you can search the soapAction in the WSDL
[soap requestURL:@"http://www.my-web.com/my-service.svc"
soapAction:@"http://www.my-web.com/my-interface/my-method"
value:myObject
completeWithDictionary:^(NSInteger statusCode, NSDictionary *dict) {
NSLog(@"%@", dict);
} failWithError:^(NSError *error) {
NSLog(@"%@", error);
}];
directly from WSDL (not recommended is slow) :
#import "SOAPEngine.h"
// TODO: your user object
MyClass myObject = [[MyClass alloc] init];
SOAPEngine *soap = [[SOAPEngine alloc] init];
soap.userAgent = @"SOAPEngine";
// service url with WSDL, and operation (method name) without tempuri
[soap requestWSDL:@"http://www.my-web.com/my-service.amsx?wsdl"
operation:@"my-method-name"
value:myObject
completeWithDictionary:^(NSInteger statusCode, NSDictionary *dict) {
NSLog(@"Result: %@", dict);
} failWithError:^(NSError *error) {
NSLog(@"%@", error);
}];
with Notifications :
#import "SOAPEngine.h"
// TODO: your user object
MyClass myObject = [[MyClass alloc] init];
SOAPEngine *soap = [[SOAPEngine alloc] init];
soap.userAgent = @"SOAPEngine";
soap.version = VERSION_WCF_1_1; // WCF service (.svc)
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(soapEngineDidFinishLoading:)
name:SOAPEngineDidFinishLoadingNotification
object:nil];
// service url without ?WSDL, and you can search the soapAction in the WSDL
[soap requestURL:@"http://www.my-web.com/my-service.svc"
soapAction:@"http://www.my-web.com/my-interface/my-method"
value:myObject];
#pragma mark - SOAPEngine Notifications
- (void)soapEngineDidFinishLoading:(NSNotification*)notific
