我注意到如果我在带有数组参数的webservice上发送一个数组,我会遇到未处理的错误,但是,当我发送纯字符串时,我可以使用字符串参数在webservice上发送数据。我搜索并跟踪线程传递数组但是,它没有用。我错过了什么吗?
client side:
LocalService.Service1Client a = new LocalService.Service1Client();
LocalService.PersonalDetail[] Entity = new LocalService.PersonalDetail[1];
LocalService.PersonalDetail Entity2 = null;
Entity2 = new LocalService.PersonalDetail();
Entity2.Firstname = "TEST";
Entity2.Lastname = "TEST";
Entity2.Middlename = "TEST";
Entity2.CreatedDate = DateTime.Today;
Entity[0] = Entity2;
a.Open();
Console.Write(a.GetLookOutList(Entity));
a.Close();
wcf server side.
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetLookOutList(PersonalDetail[] obj);
}
public class Service1 : IService1
{
public string GetLookOutList(PersonalDetail[] obj)
{
IResponse Lol = new LookOutList(obj);
return Lol.Response();
}
}
[DataContract(Name = "PersonalDetail")]
public class PersonalDetail
{
[DataMember(Name = "Firstname")]
public string Firstname
{ get; set; }
[DataMember(Name = "Middlename")]
public string Middlename
{ get; set; }
[DataMember(Name = "Lastname")]
public string Lastname
{ get; set; }
[DataMember(Name = "CreatedDate")]
public DateTime CreatedDate
{ get; set; }
}
答案 0 :(得分:1)
public string GetLookOutList(PersonalDetail[] obj)
{
IResponse Lol = new LookOutList(obj);
return Lol.Response();
}
其中一条内线是抛出异常。
要验证,请尝试以下操作:
public string GetLookOutList(PersonalDetail[] obj)
{
return "TEST";
}
这样可行。
现在您需要调试代码。将断点设置为第一行IResponse Lol = new LookOutList(obj);
并启动调试过程。您可以找到有关here特定例外的帮助。