WCF - Object as known type -> interoperable?
Actually there should be a straight forward answer to this question (is about the "Object" property below):
Having the following data contract:
[KnownType(typeof(bool))]
[KnownType(typeof(int))]
[KnownType(typeof(string))]
[KnownType(typeof(Customer))]
[KnownType(typeof(Client))]
public class Transaction
{
// properties
[DataMember(Name = "UID")]
public int UID{}
[DataMember(Name = "Type")]
public Enums.TransactionType Type{}
[DataMember(Name = "Data")]
public Object Data{}
}
and the following service contract:
public interface IService
{
[OperationContract(Name = "GetData")]
List<Transaction> GetTransact();
}
Will this be interoperable? Saying from Java, gSoap? If not, how can I make it interoperable?
Thank you.
EDIT: I just want to know if WCF k开发者_JS百科nows how to serialize/deserialize the Object from/into the known types defined.
It should be fine as long as the client can generate the types properly from the WSDL. For example depending on the client, it might change C#'s List<Transaction>
into a Transaction[]
or something fairly equivalent. You will also need to select the right binding type. Usually basicHttpBinding has the best results for interoperability.
精彩评论