How to call and parse SOAP WSDL service in Swift 2.0 at Xcode 7.1

I am new to SOAP and I don't know how to call SOAP Webservice and parse XML.I also tried searching at Google.And all the resource that I got was outdated.Is there any tutorial or examples that I can learn?Any Help?

iPhone 6, iOS 9.2

Posted on Jan 19, 2016 1:21 AM

Reply
11 replies

Jan 20, 2016 1:36 PM in response to etresoft

If you do need to use SOAP and if you only need to send and receive a few fairly simple/fixed SOAP xml structures, then you may be able to get away with not using an actual SOAP encoder/decoder.


Instead you could look at samples of the xml structures (if available) or you could look at what some kind of SOAP (demo) tool sends/receives over the wire. With this knowledge you could then create the proper xml messages using a regular format string with a few input parameters. You could similarly use regular expressions to parse out the data fields form the reply SOAP messages.

Jan 23, 2016 8:13 AM in response to etresoft

Some of the old scale large project which can't change to RESTful still use SOAP and xml parsing.So all I need is simple example which was showing how to call SOAP Service in Swfit 2.0 or above because the tutorial that i found was outdated which using NSURLConnection instead of NSURL session and the delegates method which get the data and parse the xml are completely strange to me.I really need help with that.Please help.There are also who are seeking for such tutorial too because SOAP based APIs are using in some large scale project.

Jan 23, 2016 12:52 PM in response to ColayHills

Hello again ColayHills,

I'm afraid there is nothing simple about the Simple Object Access Protocol. Here is a SOAP client on github that still seems to be maintained. It even has Swift examples. https://github.com/priore/SOAPEngine


Are you trying to do this from iOS? From a Mac, I would suggest using some 3rd party/open-source solution and calling it as an external task. For iOS, you're just SOL. You can write it yourself using the above library, NSURLConnection or NSURLSession. The library will handle the parsing for you but you will have to learn how the delegates work. I'm sure there are other libraries too, they will just be in Objective-C, which you can use with Swift. They may be pretty old though. Plus, if you are dealing with large scale projects, they might even use funky things like WSDL. That's gonna be a mess.

Jan 23, 2016 5:12 PM in response to etresoft

Actually i don't want to use SOAPengine because it's license pay.So,looks like I have to writhe by my own.So I really need a help at working with NSURLSession.

http://webindream.com/soap-with-swift/

That is the tutorial which I want all its syntax in Swift 2.1 including Its delegate method without using NSURLConnection and parsing.Any Help please??Code help is more appreciated.

Jan 23, 2016 6:06 PM in response to ColayHills

Hello again ColayHills,

Sorry. I didn't see that license. That's odd for github.


I'm afraid you have a fundamental problem here. SOAP is horribly difficult. Not just hard - exceptionally hard. Plus, there is no guarantee that any particular SOAP protocol is going to map well onto an asynchronous network architecture. I haven't used SOAP in years so I can't give you any coding help. You are not going to find anything in Swift. You can find some libraries in C (http://csoap.sourceforge.net/), some in Objective-C (https://code.google.com/p/wsdl2objc/), and some generators (http://sudzc.com/). The last time I use a native SOAP client I used EasySOAP (http://easysoap.sourceforge.net/). It is very easy but the C++ is positively ancient.


Unless someone is paying you, handsomely, by the hour, I strongly suggest that you do not attempt to write your own. You can use any Objective-C or C library out there from your Swift code. Most libraries should have an option of feeding in an XML text string. You can do your networking in NSURLSession or whatever you want and then just give the library the XML. It won't be pretty.


But I want to reiterate that unless you are being paid very well - at least 200k a year - don't walk away from SOAP - run. It is career suicide.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to call and parse SOAP WSDL service in Swift 2.0 at Xcode 7.1

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.