我注意到,如果我發送數組的webservice與數組參數,我遇到未處理的errorexception,但是,當我發送純字符串,我可以發送Web服務上的數據與字符串參數。我搜索並按照線程來傳遞數組,但它不起作用。我錯過了什麼?C#wcf傳遞數組參數,遇到System.ServiceModel.FaultException
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; }
}
您需要讓調試器運行並找出導致FaultException的基本異常。 – Paddy
@Paddy對不起,我不明白, 你說我必須尋找基地的例外.. 我必須看看「base.channel。」。 ??或者我應該點擊我發佈的「查看詳細信息」 – porknbeans
異常消息有足夠的提示如何進一步處理並自行找到錯誤。你甚至讀過它嗎? – nvoigt