我有一个 weservice 方法,
public string SearchProperties(string pPropertySearch, string pSort)
{
string[] _propSearch = pPropertySearch.Split(',');
string searchType = (_propSearch)[_propSearch.Length - 1];
List<Property> returnResults = new List<Property>();
try
{
PropertySearch _MyPropertySearch = (PropertySearch)JavaScriptConvert.DeserializeObject(pPropertySearch, typeof(PropertySearch));
returnResults = PropertyDALC.SearchPropertyNew(_MyPropertySearch, pSort, searchType, 25);
}
catch (Exception e)
{
}
string output = JavaScriptConvert.SerializeObject(returnResults);
return output;
}
PropertySearch.cs,
[Serializable]
public class PropertySearch
{
private string userId;
private string sessionId;
private string priceMin;
private string priceMax;
public string UserId
{
get { return userId; }
set { userId = value; }
}
public string SessionId
{
get { return sessionId; }
set { sessionId = value; }
}
public string PriceMin
{
get { return priceMin; }
set { priceMin = value; }
}
public string PriceMax
{
get { return priceMax; }
set { priceMax = value; }
}
public string BedsMin
{
get { return bedsMin; }
set { bedsMin = value; }
}
}
我将字符串“pPropertySearch”指定为:
"0000-0000","gghuk","6666","8888"
单击 InVoke 按钮时,将调用 Web 服务并在此行附近
" PropertySearch _MyPropertySearch = (PropertySearch)JavaScriptConvert.DeserializeObject(pPropertySearch, typeof(PropertySearch));"
它给出了这个例外,
"Cannot convert object of type 'System.String' to type 'PropertySearch'"
这段代码有什么问题。请纠正我。
我是否以错误的格式传递字符串?请帮忙。webservice中的这些序列化、反序列化概念我不知道。
任何帮助表示赞赏!