KSOAP 和 .net 服务上的奇怪行为
因此,我尝试了另一种方法来解决我之前发布的问题(http://stackoverflow.com/questions/7812507/ksoap2-double-id),
我从返回数据集更改为返回简单的字符串数组。这是 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
(简称 sse
)bodyIn
元素在以下情况下给了我 ClassCastException
获取属性,使用 getResponse()
或 getResult()
我确实可以毫无问题地获取值,但仅限于索引 1 和 2 中的值,即索引 1 和 2 中的值索引 0 总是给我抛出一个 ClassCastException 异常,所以我尝试在返回的数组上添加一个“虚拟”索引 0,然后将最终值存储在索引 1、2 和 3 上,并且它有效,我可以检索值,但 getProperty(0)
不断向我发送 ClassCastException
。有什么想法吗????很奇怪吧?
So, i tried another approach to a problem i posted earlier (http://stackoverflow.com/questions/7812507/ksoap2-double-id)
I changed from returnin a DataSet to return a simple array of string. Here's the 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
But here's the strange thing. Notice how the element 0 of my array states "dummie". That's because when retrieving the reponse of the webService, SoapSerializationEnvelope
(sse
for short) bodyIn
element gave me ClassCastException
when getting the properties, with either getResponse()
or getResult()
i could indeed get the values withouth problem, but only those in index 1 and 2, the one in index 0 always threw me a ClassCastException
, so i tried adding a "dummie" index 0 on my returning array and just store the final values on indexes 1, 2 and 3, and it worked, I can retrieve the values, but getProperty(0)
keeps sending me a ClassCastException
. Any ideas???? Pretty weird huh?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有设置 respuesta(0),所以什么也没有。这将导致类转换异常或空引用异常,具体取决于调用者。
You didn't set respuesta(0), so it's Nothing. Which would cause a class cast exception or null reference exception depending on the caller.