WSDL2Swift 0.9.0

WSDL2Swift 0.9.0

LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2019
SPMSupports SPM

Maintained by BAN Jun.

Depends on:
BrightFutures< 7.0.0, >= 6.0.0-beta.1
ISO8601>= 0
Fuzi~> 2.0


Build Status Version License Platform

Swift alternative to WSDL2ObjC making a SOAP request & parsing its response as defined in WSDL. Objective-C free.

Stubs for unit test can be implemented using Toki.

Input & Output


  • WSDL 1.1 xmls
  • XSD xmls


  • a Swift file which works as SOAP client
    • Swift 4 (Xcode 9)
    • NSURLSession for connection
    • BrightFutures for returning asynchronous requests
    • Fuzi for fast parsing xmls
    • AEXML for generating xmls



bundle install
bundle exec fastlane archive

you can build and debug with WSDL2Swift scheme of the xcodeproj. Archive build is not supported yet.

product executable is portable, as long as shipped with ./Frameworks and ./Stencils.


generate WSDL.swift from WSDL and XSD xmls:

./build/Build/Products/Release/WSDL2Swift --out path/to/WSDL.swift path/to/service.wsdl.xml path/to/service.xsd.xml

the order of input files is important. referenced XSDs should be placed immediately after referencing WSDL.

Use In App

add WSDL.swift to your project and use: (note that service type name and requeest type name are vary, depending on source WSDL)

generated code from example by w3schools temperature converter:

public struct TempConvert: WSDLService {
    public func request(_ parameters: TempConvert_CelsiusToFahrenheit) -> Future<TempConvert_CelsiusToFahrenheitResponse, WSDLOperationError> {
        return requestGeneric(parameters)


public struct TempConvert_CelsiusToFahrenheit {
    public var Celsius: String?

public struct TempConvert_CelsiusToFahrenheitResponse {
    public var CelsiusToFahrenheitResult: String?


code using the generated client:

let service = TempConvert(endpoint: "")
service.request(TempConvert_CelsiusToFahrenheit(Celsius: "23.4")).onComplete { r in
    NSLog("%@", "TempConvert_CelsiusToFahrenheit(Celsius: \"23.4\") = \(r)")

with dependencies:

pod 'WSDL2Swift'

note that pod WSDL2Swift just introduces runtime dependencies. it does not provide WSDL2Swift executable binary nor generated WSDL client Swift files.

sometimes, somewhere in your dependencies chain (transitive framework dependencies or test bundle), header search paths for libxml2 is required. see podspec to add manually.


You can specify charset of SOAP request by editing the generated code.

The following code is an example when you want to specify character code to be interpreted as utf-8.

public var characterSetInContentType: CharacterSetInContentType {
    return .utf8

By default, unspecified is set.


iOSWSDL2Swift target in xcodeproj is an example using WSDL2Swift. it generates WSDL+(ServiceName).swift at the first step of build and use it from ViewController.swift.

you need to place your WSDL and XSD xmls into exampleWSDLS folder.


usage point of view...

  • initialize Service with endpoint URL (endpoint URL can be changed after generating WSDL+(ServiceName).swift)
  • initialize request parameter with ServiceName_OperationName(...)
  • Service.request(param) to get Future that will be completed by NSURLSession completion
  • parameters and models are typed by xsd definition (even with nullability)