4
我正在使用在Visual Basic .NET 3.5中编程的Web服务接收从其他应用程序发送的JSON数组。在Web服务中接收JSON数组作为参数
我送一个JSON字符串像这样的:
[{"idRecoleccion":1,"PIN":"553648138"},{"idRecoleccion":2,"PIN":"553648138"}]
而且我接受在Visual Basic .NET代码如下:
<WebMethod()> _
Public Function ConfirmaRecol(ByVal ArrayConfirma() As cConfirmaRecoleccion) As Boolean
For X = 0 To ArrayConfirma.Length -1
' Usage example
ArrayConfirma(X).PIN
ArrayConfirma(X).idRecoleccion
End If
Next
End Function
而且我定义class cConfirmaRecolecciones这样:
Public Class cConfirmaRecoleccion
Dim p_idRecoleccion As Integer
Dim p_PIN As String
Public Property idRecoleccion() As Integer
Get
Return p_idRecoleccion
End Get
Set(ByVal value As Integer)
p_idRecoleccion = value
End Set
End Property
Public Property PIN() As String
Get
Return p_PIN
End Get
Set(ByVal value As String)
p_PIN = value
End Set
End Property
End Class
我只是想能够使用1整数和1字符串的数组是由JSON发送,这就是为什么我试图用他的方式。
几个重要事项:
- 我已经能够与具有更简单的参数,以便我必须使用Web服务的配置是正确的方法使用Web服务。
这是我由服务器得到的错误:
{"Message":"Type \u0027System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]\u0027 is not supported for deserialization of an array.","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertListToObject(IList list, Type type, JavaScriptSerializer serializer, Boolean throwOnError, IList& convertedList)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)\r\n at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromPostRequest(HttpContext context, JavaScriptSerializer serializer)\r\n at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
你大师对我如何在Visual Basic .NET接收自定义对象的数组任何其他建议吗?
任何帮助将不胜感激!
Curro,请不要在标题中重复“VB.NET”等标签。只需将其留在标签中。 – 2010-07-06 00:33:34
明白了,谢谢! – Arturo 2010-07-06 01:17:42