I wrote a block for mapping XML into objects called XMLMapper . (uses the same technique as ObjectMapper )
You can use Requests to create SOAP requests.
First create your own SOAPMessage :
class HolidayServiceMessage: SOAPMessage { var countryCode: String? override func mapping(map: XMLMap) { super.mapping(map: map) countryCode <- map["m:countrycode"] } }
Then create SOAPEnvelope as follows:
let soapMessage = HolidayServiceMessage(soapAction: "GetHolidaysAvaible", nameSpace: "http://holidaywebservice.com/HolidayService_v2") soapMessage.countryCode = "UnitedStates" let soapEnvelope = SOAPEnvelope(soapMessage: soapMessage)
Complete the submission of the SOAP request using Alamofire:
Alamofire.request("http://holidaywebservice.com/HolidayService_v2/HolidayService2.asmx?wsdl", method: .post, parameters: soapEnvelope.toXML(), encoding: XMLEncoding.soap(withAction: "http://holidaywebservice.com/HolidayService_v2#GetHolidaysAvaible"))
You can map an XML response to fast objects using the XMLMappable protocol.
source share