Я пытаюсь опубликовать на сервере, но он не подключается к серверу. На этом
Status Code: 500, Headers {"Cache-Control" = ( private ); "Content-Length" = ( 236
Я никогда не использовал SOAP API.Может кто-нибудь мне помочь?Если у вас есть лучшее решение, предоставьте мне.
import UIKit
class ViewController: UIViewController {
var is_SoapMessage = String(format: "<?xml version='1.0'
encoding='utf-8'?>\n" +
"<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/'>\n" +
"<soap:Body>\n"
+ "<QR_GetDeviceCtration
xmlns='http://www.bdmitech.com/m2b'>\n"
+ "<TerminalName>%@</TerminalName>\n"
+ "<TerminalSerial>%@</TerminalSerial>\n"
+ "<ChannelType>%@</ChannelType>\n"
+ "<SecurityKey>%@</SecurityKey>\n"
+ "</QR_GetDeviceCheckAndRegistration>\n"
+ "</soap:Body></soap:Envelope>\n"
,"wegg","gewg","gerg","gerw","khds")
override func viewDidLoad() {
super.viewDidLoad()
self.soapcall()
}
func soapcall(){
let is_URL: String = "http://27.147.34.sdfre/eckAndRegistration"
let lobj_Request = NSMutableURLRequest(url: NSURL(string: is_URL)! as URL)
//let session = URLSession.shared
//let err: NSError?
let msgLength = String(describing: is_SoapMessage.characters.count)
lobj_Request.httpMethod = "POST"
// lobj_Request.httpBody = is_SoapMessage.data(using: String.Encoding.utf8)
lobj_Request.addValue("27.43.3553.32", forHTTPHeaderField: "Host")
lobj_Request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
lobj_Request.addValue(msgLength, forHTTPHeaderField: "Content-Length")
lobj_Request.httpBody = is_SoapMessage.data(using: String.Encoding.utf8)
lobj_Request.addValue("http://27.32423.23423.245:98/dRegistration", forHTTPHeaderField: "SOAPAction")
let session = URLSession(configuration: URLSessionConfiguration.default)
let task: URLSessionDataTask = session.dataTask(with: lobj_Request as URLRequest ) { (data, response, error) in
print(response)
}
task.resume()
}
}