I always get a casting error when passing data from my application to my ASMX webservice
My WebService code
Public Function SetAlterLogTrx(ByVal qsTrx As List(Of String)) As String
Dim oStatus As New LogAlterStatusDsp
Dim iRec As Integer = 0
Using DBCONN As New SqlConnection()
Dim strConnString As String = ConfigurationManager.ConnectionStrings("Conn").ConnectionString
DBCONN.ConnectionString = sDBConnString
If qsTrx.Count = 0 Then
Return "Failed"
Else
Dim sQueryList As Array = qsTrx.ToArray
For Each sQuery As String In sQueryList
Using UpdateOutCommand As New SqlCommand(sQuery, DBCONN)
Try
With DBCONN
.Open()
iRec = UpdateOutCommand.ExecuteNonQuery()
.Close()
End With
Catch ex As Exception
Return "Failed"
End Try
End Using
Next
Return "Ok"
End If
End Using
End Function
My Client Code
dim qsArray() as string
'This array has many lines
Using oSvc As New AnfaEngine.AnfaWSSoapClient
Dim svcReplay As AnfaEngine.LogAlterStatusDsp
Dim oList As New List(Of String)
oList.AddRange(qsArray.Cast(Of String).ToList)
svcReplay = oSvc.SetAlterLogTrx(oList)
End Using
and I always get this error message:
Unable to cast object of type 'System.Collections.Generic.List`1[System.String]' to type 'WS.ArrayOfString'.
What should I do to resolve this issue.