Closed 99xs closed 8 years ago
Actually, I think I get a session ID. My code is like this so far:
override func viewDidLoad() {
super.viewDidLoad()
var soap = SOAPEngine()
soap.userAgent = "SOAPEngine"
soap.actionNamespaceSlash = false
soap.selfSigned = true
soap.version = VERSION_1_1
soap.responseHeader = true // use only for non standard MS-SOAP service
soap.envelope = "xmlns:urn=\"urn:Magento\""
soap.setValue("username", forKey: "username")
soap.setValue("password", forKey: "apiKey")
soap.requestURL("http://websiteurl/api/v2_soap/",
soapAction: "urn:Mage_Api_Model_Server_V2_HandlerAction#login",
completeWithDictionary: { (statusCode : Int,
dict : [NSObject : AnyObject]!) -> Void in
var result:Dictionary = dict as Dictionary
self.mydata = result
print(self.mydata)
}) { (error : NSError!) -> Void in
NSLog("%@", error)
}
}
But if I make another call just after this one, I won't get a result as it starts before the first one has finished.
Sorry we did not understand, you need a queue of executions ? The SOAPEngine not have a queue management, but you can see a starting point from a good project of the @irace https://github.com/irace/BRYSerialAnimationQueue, If you replacing the animation calls with the SOAP calls should be what you want.
Thank you, but that's not what I was asking. Now I know what I need. Could you please give an example of using SOAPEngine with Delegates in SWIFT?
Ok
class your-class: SOAPEngineDelegate {
var soap = [SOAPEngine]()
var verses:NSArray = [NSArray]()
override func viewDidLoad() {
super.viewDidLoad()
let soap = SOAPEngine()
soap.userAgent = "SOAPEngine"
soap.actionNamespaceSlash = true
soap.delegate = self;
soap.licenseKey = "your-license"
//soap.responseHeader = true // use only for non standard MS-SOAP service
soap.setValue("Genesis", forKey: "BookName")
soap.setIntegerValue(1, forKey: "chapter")
soap.requestURL("http://www.prioregroup.com/services/americanbible.asmx",
soapAction: "http://www.prioregroup.com/GetVerses")
}
func soapEngine(soapEngine: SOAPEngine!,
didFinishLoading stringXML: String!,
dictionary dict: [NSObject : AnyObject]!) {
var book:Dictionary = dict as Dictionary
let verses:NSArray = book["BibleBookChapterVerse"] as! NSArray
NSLog("%@", verses)
}
func soapEngine(soapEngine: SOAPEngine!, didFailWithError error: NSError!) {
NSLog("%@", error)
}
}
Thank you very much for your help.
Hi there,
Obviously, I'm very new to this. Still, I managed to make a SOAP call to a Magento website from Swift and I get a token. Problem is I don't know how to make multiple calls (like a queue) just after receiving the token. Could you please post an example?
Thank you very much in advance.