ColayHills

Q: 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

Close

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

  • All replies
  • Helpful answers

  • by etresoft,

    etresoft etresoft Jan 20, 2016 11:49 AM in response to ColayHills
    Level 7 (29,298 points)
    Mac OS X
    Jan 20, 2016 11:49 AM in response to ColayHills

    Hello ColayHills,

    That is because SOAP is outdated. It is based on XML, and really nasty XML at that. Do you have other options or do you have to use SOAP?

  • by hokanst,

    hokanst hokanst Jan 20, 2016 1:36 PM in response to etresoft
    Level 2 (300 points)
    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.

  • by ColayHills,

    ColayHills ColayHills Jan 23, 2016 8:13 AM in response to etresoft
    Level 1 (0 points)
    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.

  • by etresoft,

    etresoft etresoft Jan 23, 2016 12:52 PM in response to ColayHills
    Level 7 (29,298 points)
    Mac OS X
    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.

  • by ColayHills,

    ColayHills ColayHills Jan 23, 2016 5:12 PM in response to etresoft
    Level 1 (0 points)
    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.

  • by etresoft,

    etresoft etresoft Jan 23, 2016 6:06 PM in response to ColayHills
    Level 7 (29,298 points)
    Mac OS X
    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.

  • by ColayHills,

    ColayHills ColayHills Jan 23, 2016 10:23 PM in response to ColayHills
    Level 1 (0 points)
    Jan 23, 2016 10:23 PM in response to ColayHills

    so sad,Anyone,anyone who have experience of consuming SOAP Webservice in latest swift?I really do need help.@etresoft,Really thanks for being with me with this help.SOAPEngine is working with liscense key,you can check below of its page its said "Simulator Free,1Product €17,9,Multiple Product...."That's y I really do need help

  • by mjain_jkv,

    mjain_jkv mjain_jkv Jun 29, 2016 2:07 AM in response to ColayHills
    Level 1 (4 points)
    Jun 29, 2016 2:07 AM in response to ColayHills
  • by rubelbd82,

    rubelbd82 rubelbd82 Sep 16, 2016 7:24 AM in response to ColayHills
    Level 1 (4 points)
    Sep 16, 2016 7:24 AM in response to ColayHills

    Hello ColayHills. I'm the author of http://webindream.com/soap-with-swift/

    I've modified my article to make it compatible with Swift 2.1.1

    If you haven't find any solution yet, please check it again.

  • by rubelbd82,

    rubelbd82 rubelbd82 Sep 16, 2016 7:25 AM in response to ColayHills
    Level 1 (4 points)
    Sep 16, 2016 7:25 AM in response to ColayHills

    You may try http://webindream.com/soap-with-swift/

     

    I've modified this article to make it compatible with Swift 2.1.1