【问题标题】:Weird behavior on KSOAP and .net ServicesKSOAP 和 .net 服务上的奇怪行为
【发布时间】:2011-10-18 20:58:39
【问题描述】:

所以,我尝试了另一种方法来解决我之前发布的问题 (http://stackoverflow.com/questions/7812507/ksoap2-double-id)

我从返回 DataSet 更改为返回一个简单的字符串数组。这是webMethod

<WebMethod(Description:="Almacena una lectura, la posición del lecturista y revisa si sigue activo el servicio")> _
Public Function guardarDatos(ByVal Lecturas As Object, ByVal id_lec As String, ByVal usuario As String, ByVal sobrelectura As String, ByVal latitud As String, ByVal longitud As String, ByVal precision As String, ByVal pin As String) As String()
    Dim respuesta As String() = {"dummie", "0", "0", "0"}
    If ingresarLecturas(Lecturas, id_lec, usuario, sobrelectura) Then
        respuesta(1) = "1"
    End If
    If guardaLocalizacion(id_lec, usuario, latitud, longitud, precision, pin) Then
        respuesta(2) = "1"
    End If
    If gpsActivo() Then
        respuesta(3) = "1"
    End If
    Return respuesta
End Function

但奇怪的是。请注意我的数组的元素 0 是如何表示“dummie”的。那是因为在检索 webService 的响应时,SoapSerializationEnvelope(简称ssebodyIn 元素在获取属性时给了我ClassCastExceptiongetResponse()getResult() 我确实可以得到没有的值问题,但只有索引 1 和 2 中的那些,索引 0 中的那个总是给我一个ClassCastException,所以我尝试在我的返回数组上添加一个“虚拟”索引 0,并将最终值存储在索引 1、2 和3,它起作用了,我可以检索值,但getProperty(0) 不断向我发送ClassCastException。有任何想法吗????很奇怪吧?

【问题讨论】:

    标签: .net web-services ksoap2


    【解决方案1】:

    你没有设置 respuesta(0),所以没什么。这将导致类转换异常或空引用异常,具体取决于调用者。

    【讨论】:

    • 当我将变量 respuesta 定义为 String 数组时,注意我还定义了数组的内容,respuesta(0) 是 String "dummie"
    猜你喜欢
    • 1970-01-01
    • 2021-10-01
    • 2014-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-09
    • 1970-01-01
    相关资源
    最近更新 更多