Operation not supported in the WCF Test Client

前端 未结 4 692
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 13:01

I created a WCF service and to the default service I added another operation contract on the main DataContract:

[OperationContract]
void DoSomething(UserData         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-18 13:36

    Add the attribute to your 'UserData' class [KnownType(typeof(CompositeType))]

    Like:

    [DataContract]
    [KnownType(typeof(CompositeType))]
    public class UserData 
    {
       [DataMember]
       public uint One { get; set; }
    
       [DataMember]
       public CompositeType Extra { get; set; }
    
       public UserData() { ctor. code }
    }
    

    http://msdn.microsoft.com/en-us/library/ms730167.aspx

    Edit:

    http://msdn.microsoft.com/en-us/library/system.operatingsystem.aspx

    The OperatingSystem class has a few properties which relate to other classes. You could include all these classes in the known types but the dependency chain could get rather large and I would highly recommend not using the Operating System class at all.

    You should work out what information you actually need from the Operating System class and create your own DTO to pass back in the response. That way you can ensure all the types are easily definable on your contract.

提交回复
热议问题