简体   繁体   中英

WCF service method arguments

I have a basicHttpBinding WCF service. Via the contract I expose a method that takes in as an argument an IEnumerable<myType> . myType class inherits from ISerializable and I implement GetObjectData() and the constructor to myType(SerializationInfo info, StreamingContext context)

When I leave the method in my WCF contract that takes IEnumerable<myType> as an argument, I can no longer really use the service. I'm able to add a reference but it doesn't actually expose any of the methods I'm expecting.

I've done some reading I've seen many people who let people pass arguments to their network methods use the [XmlSerializerFormat] attribute.

I take it I am trying to use binary serialization and that's not working. Are there any type of WCF services that lets one transmit binary or do they all have to be XML Serialized? If so how do I make sure myType is XML Serializable.

You should read about and implement Data Contract Serialization. See Using Data Contracts . Do not use the XML Serializer unless you need precise control over the "shape" of the XML on the wire.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM