有什么问题我正在尝试使用Soap API发布数据,但显示出HTTP 500错误

时间:2019-03-25 10:03:04

标签: ios swift soap alamofire

我正在尝试在服务器中发帖,但此服务器未连接到服务器

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()        
    }
}


0 个答案:

没有答案