ios - How to pass parameters in SOAP web service having a Method? -


i getting confusion use soap service below one. till never used soap based services. service inthis service need pass 4 vlaues parameters username,password,ipaddress,devicename.and output come in json format. how achieve me. http://workforce.wifisocial.in/webservicesmethods/employeeswebservice.asmx?op=employeesloginmethod

all need http post request , pass right xml data , set http headers:

func soaprequest(username:string, password:string, ipaddress:string, devicename:string){          if let url = nsurl.init(string: "http://workforce.wifisocial.in/webservicesmethods/employeeswebservice.asmx"){              let request = nsmutableurlrequest(url: url)              let requestbody = "<?xml version=\"1.0\" encoding=\"utf-8\"?><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/\"><soap:body><employeesloginmethod xmlns=\"http://tempuri.org/\"><username>\(username)</username><password>\(password)</password><ipaddress>\(ipaddress)</ipaddress><devicename>\(devicename)</devicename></employeesloginmethod></soap:body></soap:envelope>"              request.httpmethod = "post"              request.httpbody = requestbody.datausingencoding(nsutf8stringencoding)              request.setvalue("text/xml", forhttpheaderfield: "content-type")              request.setvalue("\"http://tempuri.org/employeesloginmethod\"", forhttpheaderfield: "soapaction")              nsurlsession.sharedsession().datataskwithrequest(request, completionhandler: { (data, response, error) in                  guard error == nil && data != nil else{                      //handle error                      return                  }                  if let responsestring = string.init(data: data!, encoding: nsutf8stringencoding){                      print("\(responsestring)")                  }                  //..........                  //parse xml response data                  //.........              }).resume()                        }                }


Comments