我有我從webservice調用的以下方法 - 我不斷收到「無法序列化,因爲它沒有無參數構造函數」的錯誤消息。Webservice - 無法序列化,因爲它沒有無參數的構造函數
[WebMethod]
public ArrayList GetPayers()
{
string PROVIDER_JSON = "";
ArrayList list = new ArrayList();
using (var webClient = new System.Net.WebClient())
{
PROVIDER_JSON = webClient.DownloadString("https://www.eligibleapi.com/resources/information-sources.json");
List<EligibleProviderType2> UserList = JsonConvert.DeserializeObject<List<EligibleProviderType2>>(PROVIDER_JSON);
for (int i = 0; i < UserList.Count; i++)
{
foreach (string inventoryItem in UserList[i].PayerName)
{
list.Add(new
{
PayerID = UserList[i].PayerID,
PayerName = inventoryItem
});
}
}
return list;
}
}
哪個調用這個類 - 我認爲它有一個無參數的構造函數?
[JsonObject(MemberSerialization.OptIn)]
public class EligibleProviderType2
{
EligibleProviderType2(){}
[JsonProperty(PropertyName = "payer_id")]
public string PayerID { get; set; }
[JsonProperty(PropertyName = "names")]
public IList<string> PayerName { get; set; }
} // EligibleProvider
ASMX是一項傳統技術,不應用於新開發。 WCF或ASP.NET Web API應該用於Web服務客戶端和服務器的所有新開發。一個暗示:微軟已經在MSDN上退役了[ASMX Forum](http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/threads)。 –