title: Consume a SOAP WebService with WSDL
body: <p>I have done a tutorial for using a SOAP WeService in SWIFT:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, UITextFieldDelegate, NSURLConnectionDelegate, NSXMLParserDelegate {
  
      var mutableData: NSMutableData = NSMutableData.alloc()
      var currentElementName: NSString = ""
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          var soapMessage = "&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'&gt;&lt;soap:Body&gt;&lt;CelsiusToFahrenheit xmlns='http://www.w3schools.com/webservices/'&gt;&lt;Celsius&gt;0&lt;/Celsius&gt;&lt;/CelsiusToFahrenheit&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;"
  
  
  
          var urlString = "http://www.w3schools.com/webservices/tempconvert.asmx"
  
          var url = NSURL(string: urlString)
          var theRequest = NSMutableURLRequest(URL: url!)
          var msgLength = String(count(soapMessage))
  
  
          theRequest.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
          theRequest.addValue(msgLength, forHTTPHeaderField: "Content-Length")
          theRequest.addValue("http://www.w3schools.com/webservices/CelsiusToFahrenheit", forHTTPHeaderField: "SOAPAction")
          theRequest.HTTPMethod = "POST"
          theRequest.HTTPBody = soapMessage.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
          var connection = NSURLConnection(request: theRequest, delegate: self, startImmediately: true)
          connection?.start()
          if(connection == true) {
              var mutableData : Void = NSMutableData.initialize()
          }
      }
  
  
  
      func connection(connection: NSURLConnection!, didReceiveResponse response: NSURLResponse!) {
          mutableData.length = 0;
      }
  
      func connection(connection: NSURLConnection!, didReceiveData data: NSData!) {
          mutableData.appendData(data)
      }
  
  
      func connectionDidFinishLoading(connection: NSURLConnection!) {
          var xmlParser = NSXMLParser(data: mutableData)
          xmlParser.delegate = self
          xmlParser.parse()
          xmlParser.shouldResolveExternalEntities = true
  
      }
  
      func parser(parser: NSXMLParser,
          didStartElement elementName: String,
          namespaceURI: String?,
          qualifiedName qName: String?,
          attributes attributeDict: [NSObject : AnyObject]) {
          currentElementName = elementName
      }
  
      func parser(parser: NSXMLParser, foundCharacters string: String?) {
          if currentElementName == "CelsiusToFahrenheitResult" {
              println(string)
          }
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
  }
  </code></pre>
  
  <p>It's works, I get the temperature converted, I want to implement this on my web service, but I don't know how to do, I have:</p>
  
  <ul>
  <li>a url: <a href="https://ip/webservice/contactfile.wsdl">https://ip/webservice/contactfile.wsdl</a>, it contain my xml</li>
  <li>and this url: <a href="https://ip/webservice/server.php">https://ip/webservice/server.php</a></li>
  </ul>
  
  <p>But I don't know how to do because in the tutorial I put the xml in a variable, and where I put the server url, and how to call a function of the wsdl file ?</p>