Webservice和Android用Ksoap2写的Kolin

时间:2018-05-30 05:59:44

标签: android soap kotlin android-ksoap2

你好,我一直在尝试重建w3学校的tempconverter webservice一段时间了。到目前为止,这也很有效。但是,从我的Android应用程序访问我的服务器时,我收到以下错误消息:

  

SoapFault - faultcode:'soap:Client'faultstring:'Unmarshalling Error:unexpected element(uri:“http://soapservicetest/”,local:“input”)。预期元素是< {} input> 'faultactor:'null'detail:null

我的代码如下:

fun getResultFromInput(input: Int?){
    //new SoapRequest soapRequest = new SoapRequest; SoapReq
    val request = SoapObject(NAMESPACE, METHOD_NAME)
    val celsiusPI = PropertyInfo()
    celsiusPI.setName("input")
    celsiusPI.value = input
    celsiusPI.setType(Double::class.javaPrimitiveType)
    request.addProperty(celsiusPI)
    val envelope = SoapSerializationEnvelope(
            SoapEnvelope.VER11
    )
    envelope.env = "http://schemas.xmlsoap.org/soap/envelope/"
    envelope.bodyOut = request
    envelope.encodingStyle = SoapSerializationEnvelope.ENC2003
    envelope.dotNet = true
    envelope.setOutputSoapObject(request)
    val androidHttpTransport = HttpTransportSE(URL)
    try {
        androidHttpTransport.call(SOAP_ACTION, envelope)
        response = responseLocal.toString()
    }catch (e: Exception){
        e.printStackTrace()
    }catch (t: SocketTimeoutException) {
        t.printStackTrace();
    } catch (i: IOException) {
        i.printStackTrace();
    }
}

SoapFault被异常捕获块捕获但我没有得到任何Webservice的响应。但是,如果我用例如wsdlbrowser.com进行测试,一切正常。

有人有想法可以帮助我吗?

0 个答案:

没有答案