     } catch let error as NSError {
       print("Error code: \(error.code)")
     }
-
   	return nil
   }
 

    for (key, substitution) in substitutions {
      print("\(key) : \(substitution)")
      // TODO: Update parsedURL object accordingly
      // Probably using reflection...
    }

    return parsedURL!.string
  }


  * Foundation's NSURLComponents class.
  */
  public func getServiceURL(spec: String, replacements: [String:AnyObject]?) -> String? {
    var substitutions: [String:AnyObject] = replacements ?? [:]
    let service = getService(spec);
    let credentials = service?["credentials"] as? [String:AnyObject]
    if (credentials == nil) {
        return nil;
    }

    let url: String?
    if substitutions["url"] != nil {
      url = credentials![substitutions["url"] as! String] as? String
    } else {
      url = credentials!["url"] as? String ?? credentials!["uri"] as? String
    }

    if (url == nil) {
