//我写这个就是为了验证MessageHeader和MessageHeaderArray的不同 //服务端 //这是消息协定 [MessageContract] public class UserMessageArray { [MessageHeaderArray] public string[] NameList; [MessageBodyMember] public string Remark; } [MessageContract] public class UserMessage { [MessageHeader] public string[] NameList; [MessageBodyMember] public string Remark; } //这是服务实现 public class MessageService : IMessageService { public UserMessageArray GetMessageArray(UserMessage request) { List<string> list = new List<string>(request.NameList); list.Add("wa3ha"); return new UserMessageArray { NameList = list.ToArray<string>(), Remark = "这是使用MesageHeaderArray" }; } } //客户端调用 string[] nameList = new string[] { "waha", "wa1ha", "wa2ha" }; string remark = "这是使用MesageHeader"; Console.WriteLine(remark); foreach (var item in nameList) { Console.WriteLine(item); } myClient.GetMessageArray(ref nameList,ref remark); foreach (var item in nameList) { Console.WriteLine(item); } Console.WriteLine(remark);
调用后报的错为:反序列化操作“GetMessageArray”的响应消息的正文时出现错误。在行 1、位置 349