我使用服务和数据合同在Windows应用程序中托管WCF服务
[ServiceContract]
[FaultContract(typeof(object))]
[ServiceKnownType(typeof(busSample))]
public interface IUPSBusinessTier
{
[OperationContract]
string TestMethod1(string astrName);
[OperationContract]
void TestMethod2(busSample abusSample);
[OperationContract]
busSample TestMethod3(string astrName);
[OperationContract]
string TestMethod4(object astrName);
}
[DataContract]
public class busSample
{
[DataMember]
public string istrName { get; set; }
public busSample()
{
this.istrName = "ABC";
}
}在使用WCFTestClient测试服务时,收到类似这样的错误:“反序列化程序不知道要反序列化哪个类型。请检查正在序列化的类型是否与正在反序列化的enter code here类型具有相同的约定。”
发布于 2017-02-23 02:47:54
我认为您只需要将错误协定属性从类移动到方法上。
[ServiceContract]
//[FaultContract(typeof(object))]
[ServiceKnownType(typeof(busSample))]
public interface IUPSBusinessTier
{
[FaultContract(typeof(object))]
[OperationContract]
string TestMethod1(string astrName);
[FaultContract(typeof(object))]
[OperationContract]
void TestMethod2(busSample abusSample);https://stackoverflow.com/questions/41755362
复制相似问题