Я хочу загрузить изображение на сервер подключиться с мылом с помощью SWIFT - PullRequest
0 голосов
/ 08 июля 2019

Я хочу загрузить изображение на сервер, подключиться с помощью SOAP, используя SWIFT но я должен ответить значение от мыла ниже

Response: Optional(<NSHTTPURLResponse: 0x281a1a780> { URL: http://xxx.xx.xx.xx/Projectervice/imageService.asmx?op=Upload } { Status Code: 400, Headers {
    "Cache-Control" =     (
        private
    );
    "Content-Length" =     (
        0
    );
    "Content-Type" =     (
        "text/xml; charset=utf-8"
    );
    Date =     (
        "Mon, 08 Jul 2019 07:37:10 GMT"
    );
    Server =     (
        "Microsoft-IIS/8.5"
    );
    "X-AspNet-Version" =     (
        "4.0.30319"
    );
    "X-Powered-By" =     (
        "ASP.NET"
    );
} })

Body: Optional()
[![image for Soap web service][1]][1]
I don't understand this response... and why the body does not have value



    func uploadImageToserver(photo: String) -> Void 
    {
    let is_URL: String = "http://xx.xx.xx.xx/Projectervice/imageService.asmx?op=Upload"

            let lobj_Request = NSMutableURLRequest(url: NSURL(string: is_URL)! as URL)
            let session = URLSession.shared

            lobj_Request.httpMethod = "POST"
            lobj_Request.httpBody = is_SoapMessage.data(using: String.Encoding.utf8)
            lobj_Request.addValue("xxx.xx.xx.xx", forHTTPHeaderField: "Host")
            lobj_Request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
            lobj_Request.addValue(String(is_SoapMessage.count), forHTTPHeaderField: "Content-Length")
            lobj_Request.addValue("http://tempuri.org/Upload", forHTTPHeaderField: "SOAPAction")

            let task = session.dataTask(with: lobj_Request as URLRequest, completionHandler: {data, response, error -> Void in
                print("Response: \(String(describing: response))")
                let strData = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
                print("Body: \(String(describing: strData))")

                if error != nil
                {
                    print("Error: " + error.debugDescription)
                }

            })
            task.resume()
        }





     [1]: https://i.stack.imgur.com/KBJ7T.jpg
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...