Passing custom objects to a web service

前端 未结 4 1059
盖世英雄少女心
盖世英雄少女心 2021-02-07 16:17

I have a need to pass a custom object to a remote web service. I have read that it may be necessary to implement ISerializable, but I\'ve done that and I\'m encountering difficu

4条回答
  •  鱼传尺愫
    2021-02-07 17:02

    Edit: removed the part about [Serializable]

    Are you creating the service, or consuming it?

    To create an object which can be passed as a parameter of a webmethod, you don't have to do anything special. That is if you're creating an asmx webservice.

    OTOH, If you're creating a WCF service then you have to mark the class with [DataContract] and all the members you want to be serialized with [DataMember].

    If you're consuming the webservice, then the proxy classes for the object to pass should be generated when you added the service reference. You just have to use them.

提交回复
热议问题