0
我有以下的Web服務:爲什麼webservice返回null?
<%@ WebService Language="VB" Class="WebService" %>
Imports System.Web
Imports System.Web.Script.Services
Imports System.Web.Services
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class WebService
Inherits System.Web.Services.WebService
Public Class Person
Public FirstName As String
Public LastName As String
Public Sub New(ByVal m_FirstName As String, ByVal m_LastName As String)
End Sub
End Class
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
<WebMethod()> _
Public Function GetPersons() As List(Of Person)
Dim lst As List(Of Person) = New List(Of Person)
lst.Add(New Person("firstname_1", "surname_1"))
lst.Add(New Person("firstname_2", "surname_2"))
Return lst
End Function
End Class
但它返回:
{"d":[{"FirstName":null,"LastName":null},{"FirstName":null,"LastName":null}]}
它應該返回:
{"d":[{"FirstName":"firstname_1","LastName":"surname_1"},{"FirstName":"firstname_2","LastName":"surname_2"}]}
我在做什麼錯?
就是這樣!謝謝。 – oshirowanen