我有一个Protobuf WCF服务。当我食用它时,一切正常。 数据是Protobuf,并且每件事都很好。
但是现在我想使用与Protobuf属性相同的类 没有Protobuf。有人能怎样做到这一点? 我想使用没有protobuf的Protobuf实现的服务。 而且我不想改变/添加另一个确切的类只是为了两种方式。
编辑:
var customBinding = new System.ServiceModel.Channels.CustomBinding();
customBinding.Elements.Add(new System.ServiceModel.Channels.TextMessageEncodingBindingElement(System.ServiceModel.Channels.MessageVersion.Soap11, System.Text.Encoding.UTF8));
var httpsBindingElmnt = new System.ServiceModel.Channels.HttpsTransportBindingElement();
httpsBindingElmnt.MaxReceivedMessageSize = 2147483647;
httpsBindingElmnt.UseDefaultWebProxy = true;
//httpsBindingElmnt.ReaderQuotas.MaxStringContentLength = 2147483647;
//httpsBindingElmnt.ReaderQuotas.MaxBytesPerRead = 2147483647;
//httpsBindingElmnt.ReaderQuotas.MaxArrayLength = 2147483647;
//httpsBindingElmnt.ReaderQuotas.MaxDepth = 2147483647;
//httpsBindingElmnt.ReaderQuotas.MaxNameTableCharCount = 2147483647;
//httpsBindingElmnt.ReceiveTimeout = new TimeSpan(0, 30, 0);
//httpsBindingElmnt.Name = "VaultBasicHttpBinding";
httpsBindingElmnt.MaxBufferSize = 2147483647;
httpsBindingElmnt.MaxBufferPoolSize = 2147483647;
//httpsBindingElmnt.ReceiveTimeout = new TimeSpan(0, 30, 0);
customBinding.Elements.Add(httpsBindingElmnt);
//string address = "https://adress/MobileService.svc";
//Uri baseAddress = new Uri(address);
//ServiceHost host = new ServiceHost(MobileService.MobileServiceClient), baseAddress);
//ChannelFactory<MobileService.MobileServiceClient> factory = new ChannelFactory<MobileService.MobileServiceClient>(customBinding, address);
//MobileService.MobileServiceClient client = factory.CreateChannel();
MobileService.MobileServiceClient client = new MobileService.MobileServiceClient(customBinding,
new EndpointAddress("https://adress/MobileService.svc"));
//MobileService.MobileServiceClient client = new MobileService.MobileServiceClient(customBinding,
// new EndpointAddress("http://127.0.0.1:4501/MobileService.svc"));
client.Endpoint.EndpointBehaviors.Add(new ProtoBuf.ServiceModel.ProtoEndpointBehavior());
之后我使用客户端对象函数。