0
votes

I am testing the WCF facility with the AdventureWorks SQL Server database (The table name Person).

When testing it in the wcftestclient.exe, it gives red icon and says:

This Operation is not supported in the WCF test client because it uses type AdventureWorksDbWcf.Person

This is the service.svc.cs service class.

namespace AdventureWorksDbWcf
{   
    public class Service : IService
    {
        AW_DataClassesDataContext db = new AW_DataClassesDataContext();

        public Person GetOnePerson(int BusinessEntityID)
        {
            var _person = from one in db.Persons
                          select one;

            Person onlyOnly;

            return onlyOnly = _person.First<Person>();

        }

        public List<Person> ListOfPeople()
        {
            var _person = from one in db.Persons
                          select one;

            List<Person> list = _person.ToList();

            return list;
        }
    }
}

Update: this is the IService

[ServiceContract] public interface IService { [OperationContract] Person GetOnePerson(int BusinessEntityID);

    [OperationContract]
    List<Person> ListOfPeople();

}

Have I missed something?

Please advise me.

thanks,

2
What does your class AdventureWorksDbWcf.Person look like??marc_s
This is the sample database provided by Microsoft. Name AdventureWorks200R2.darking050
Sql server has nothing to do with the error.idstam
@darking050: I know which database it is - but what does your C# class for that table look like??? I assume you probably don't have the necessary WCF attributes on it - which is why the WCF Test Client can't call that service...... are you using Linq-to-SQL or Entity Framework?? (or something else - and if so: what do you use??)marc_s
The WCF Test Client doesn't work with complex types. You'll have to write your own test harness.John Saunders

2 Answers

1
votes

You have to decorate the Person class with the appropriate [DataContract] attribute and the fields you'd like to expose with [DataMember].

If you are using the DataEntity or LinqToSQL, which auto-generate classes for the table, note that is best practice to create a "data" class to be used by the service instead of sending a class that is part of your business logic. Take a look at the IDesign's WCF coding standards.

0
votes

Check the Person classes implementation but i think it should be good because it is a generated class if i'm not mistaken.

Does your interface have the right Service Contract and Operation Contracts?

WCF tutorial