1
我想在system.servicemodel.Channels.Message
中發送一個自定義對象。像如何在WCF中發送自定義對象消息
public class person
{
string Id;
string Name;
}
MessageVersion mv = MessageVersion.Create(Soap12);
String action = "Msg";
Message msg = Message.Create(mv, action, new person());
serviceref.ProcessMsg(msg) // this is my service reference in client
//when i tried to access this in Service like
person p = msg.GetBody<person>()
//I am getting an serialization exception
//I have the Person class on both client and service side
有人可以幫我找出我的錯誤嗎?
嘿,我試過這個,但我的服務合同的輸入和輸出只有System.ServiceModel.Channel.Message。由於這個人不是直接的投入,它不會幫助我,我想。 – realn
@realn - 如果您使用了另一種CreateMessage方法 - 如果使用XmlObjectSerializer的第四個參數:[Message.CreateMessage方法(MessageVersion,String,Object,XmlObjectSerializer)](http://msdn.microsoft.com/zh-cn/ com/en-us/library/ms195454.aspx) – Tim
第1行位置錯誤695.期望元素'Person'來自命名空間'http://schemas.datacontract.org/2004/07/DCS'..遇到'元素'名稱爲'string',命名空間爲'http://schemas.microsoft.com/2003/10/Serialization/'。 – realn