简体   繁体   中英

C# WCF Client <--> Service Behavior switching

lets say I want to have a Service that uses 2 different forms of serialization and i have a client that has 2 buttons, 1 for the first behavior (XML) and the second one for lets say (Protobuf)

Is there something I need to do in order to let the client choose which serilization should be used?

I got 2 endpointBehaviors in my app.config for the service. XML and Protobuf.

Am I missing something? My Interface got only the Protocontract attribute And my DataContract got all of the protoMember attributes.

Anyone knows what I want to do and can help me out? Sorry for no code, its theorem at this point.

Provide you code please.

I think you miss the second interface. You need an Interface for each form of serialization.

Something like this:

[ServiceContract]
public interface IFirstService
{
    //Methods
}

[ServiceContract]
public interface ISecondService
{
    //Methods
}

[ServiceBehavior]
public class YourClass: IFirstService, ISecondService
{
    //Methods
}

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