WCF - Object as known type -> interoperable?

£可爱£侵袭症+ 提交于 2019-12-12 12:27:49

问题


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 knows how to serialize/deserialize the Object from/into the known types defined.


回答1:


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.



来源:https://stackoverflow.com/questions/5980121/wcf-object-as-known-type-interoperable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!