I need to make a SOAP API request and retrieve response in Swift. I am new in SOAP API and Swift. I have an API path, API Method and Input Parameters. The output is in JSON.
as i understand from your question you don't need full soap framework to make call and handle responses.In such case you should use simple xml parser and construct your own soap xml calls.
i will advise you use to use cocoapods and integrate AEXML into your project
Here it's simple xml soap format to make call
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Header> <m:Trans xmlns:m="http://www.w3schools.com/transaction/" soap:mustUnderstand="1">234</m:Trans> </soap:Header> <soap:Body> <m:GetStockPrice> <m:StockName>AAPL</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
and it how could you construct it with AEXML
let soapRequest = AEXMLDocument() let attributes = ["xmlns:xsi" : "http://www.w3.org/2001/XMLSchema-instance", "xmlns:xsd" : "http://www.w3.org/2001/XMLSchema"] let envelope = soapRequest.addChild(name: "soap:Envelope", attributes: attributes) let header = envelope.addChild(name: "soap:Header") let body = envelope.addChild(name: "soap:Body") header.addChild(name: "m:Trans", value: "234", attributes: ["xmlns:m" : "http://www.w3schools.com/transaction/", "soap:mustUnderstand" : "1"]) let getStockPrice = body.addChild(name: "m:GetStockPrice") getStockPrice.addChild(name: "m:StockName", value: "AAPL") println(soapRequest.xmlString)
after than preparing your soap calls you can use any networking library