我试图建立我的第一个应用迅速和我有,当我试图消耗SOAP Web服务的麻烦.. 下面是方法:迅速Web服务通信
@IBAction FUNC callWebService(发件人: AnyObject){
var userName:NSString = "abc"
var password:NSString = "def"
var soapMsg = "<?xml version='1.0' encoding='UTF-8'?><soap:Envelope xmlns:xsi='http://87.106.20.80:8080/axis2/services/app2beeService?wsdl' xmlns:xsd='http://localhost:8080/beeSmartWS' xmlns:soap='http:/bee.myservice.com/userLogin'><soap:Body><userLogin xmlns 'http://87.106.20.80:8080/axis2/services/app2beeService?wsdl/userLogin><:userId>" + userName + "</userId><password>" + password + "</password></userLogin></soap:Body></soap:Envelope>"
//let soapAction = "http://bee.myservice.com/userLogin"
//let urlString = "http://bee.myservice.com/"
let urlString: String = "http://bee.myservice.com/"
var url: NSURL = NSURL(string: urlString)!
//var request: NSURLRequest = NSURLRequest(URL: url)
var request = NSMutableURLRequest(URL: url)
var msgLength = String(countElements(soapMsg))
request.HTTPMethod = "POST"
request.HTTPBody = soapMsg.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
request.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.addValue(msgLength, forHTTPHeaderField: "Content-Length")
request.addValue("http://bee.myservice.com/userLogin", forHTTPHeaderField: "Action")
var connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: true)!
connection.start()
println(request)
var response: NSURLResponse?
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: nil) as NSData?
if let httpResponse = response as? NSHTTPURLResponse {
println("error \(httpResponse.statusCode)")
println(response)
}
}
}
我没有得到任何回应,当我遇到这个请求
Web服务的详细信息发送: Web服务类型:Axis2中(Java和基于SOAP) Web服务的WSDL链接:http://87.106.20.80:8080/axis2/services/app2beeService?wsdl目标命名空间:http://bee.myservice.com SOAP动作:添加/ USERLOGIN目标命名空间
你得到一个错误代码?注意:NSURLSession比旧的NSURLConnection更可取。你不需要使用Alamofire,但是你应该使用NSURLSession。 –
当我使用我的本地机器(http:// localhost:8080/beeSmartWS /)上运行的web服务的url但其他url(目标名称空间)返回错误代码500 – pioneerhear