Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operation not supported in the WCF Test Client

Tags:

c#

wcf

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

[OperationContract]
void DoSomething(UserData data);

Then I have something like this (simplified for the purpose of example) below. The problem is that even though ALL classes in the hierarchy are decorated with DataContract and ALL their members decorated with DataMember, when I use the WCF Test Client it has a red icon indicating that "the operation is not supported in the WCF test client".

[DataContract]
public class UserData {
   [DataMember]
   public uint One { get; set; }

   [DataMember]
   public CompositeType Extra { get; set; }

   public UserData() { ctor. code }
}


[DataContract]
public class CompositeType {
    [DataMember]
    public uint Two { get; set; }

    public UserData() { ctor code }
}
like image 363
Lord of Scripts Avatar asked Mar 23 '12 21:03

Lord of Scripts


1 Answers

OK, having gone through the whole thing (thanks to all for the tips) the solution was this:

  • IsReference attribute in DataContract was not needed at all
  • IsOneWay attribute in DataContract was not needed at all even when OperationContract was returning void.
  • KnownType was also not needed provided all the subtypes in the hierarchy were mine, in other words defined by me rather than .NET and marked with DataContract or DataMember as appropriate
  • Getting rid of OperatingSystem and building a wrapper DataContract that extracted the necesary information from OperatingSystem got around the issue.

Now there is no error in the WCF Test Client

like image 93
Lord of Scripts Avatar answered Oct 22 '22 11:10

Lord of Scripts