WCF: DataContract + ServiceContract

Hi,

It's not possible to create a class with the [ServiceContract] attribute that have some property with the [DataMember] attribute?

It's not possible to create a class with the [DataContract] attribute that have some function with the [OperationContract] attribute?

It's not possible to create a class with the [DataContract] and [ServiceContract] attributes?

With this model I need to divide functions and datas. How can i adapt your SOA model to my OOP mind?

Thank you.

[ServiceContract(SessionMode =SessionMode.Required)]

publicclassDoubleValidator

{

private Validators.DoubleValidator m_val;

[OperationContract]

publicvoidConstructor(string val)

{

m_val =new Validators.DoubleValidator(val);

}

[OperationContract]

publicbool IsValid()

{

return true;

}

}

And not:

[ServiceContract(SessionMode =SessionMode.Required)]

publicclassDoubleValidator

{

private Alexey.Data.Validators.DoubleValidator m_val;

[OperationContract]

publicDoubleValidator(string val)

{

m_val =new Validators.DoubleValidator(val);

}

[DataMember]

publicboolIsValid

{

get{ return true; }

}

}

[7398 byte] By [GukezhevAlexey] at [2007-12-24]
# 1

Your OOP mind should be thinking of service design separate from your existing business components and implementation. Here's the process from a very high level:

  • Design a service contract as an interface, not a class. That interface has operations that you expect to be called by clients and they should be logically related (i.e., IMyServiceContract, IMyAdminContract).
  • Any complex types that need to be serialized to operations on the contract should be data contracts. If you have existing types you can recompile, you can turn them into data contracts, but they don't have operations, just members you expose for serialization.
  • Implement the service contract on a service type (the class).

Read Chapter 1 of my book and see if that helps you.

www.thatindigogirl.com

MicheleLerouxBustamante at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Communication Foundation (Indigo)...

Visual Studio Orcas

Site Classified