package Proto.Common;
message Task
{
optional int32 Id = 1;
optional DateTime CreatedAt = 2;
optional string CreatedBy = 3;
enum TaskPriority
{
Low = 0;
Medium = 1;
High = 2;
}
optional TaskPriority Priority = 4;
optional string Content = 5;
}
* This source code was highlighted with Source Code Highlighter .
using System;
using System.Runtime.Serialization;
namespace Proto.Common
{
[DataContract]
public class Task
{
[DataMember(Order = 1)]
public int Id { get ; set ; }
[DataMember(Order = 2)]
public DateTime CreatedAt { get ; set ; }
[DataMember(Order = 3)]
public string CreatedBy { get ; set ; }
[DataMember(Order = 4)]
public TaskPriority Priority { get ; set ; }
[DataMember(Order = 5)]
public string Content { get ; set ; }
}
}
* This source code was highlighted with Source Code Highlighter .
using System.ServiceModel;
namespace Proto.Common
{
[ServiceContract]
public interface ITaskManager
{
[OperationContract]
Task[] GetTasks();
}
}
* This source code was highlighted with Source Code Highlighter .
<? xml version ="1.0" ? >
< configuration >
< system.serviceModel >
< services >
< service name ="Proto.Server.TaskManager"
behaviorConfiguration ="Proto.Server.ServiceBehavior" >
<!-- Service Endpoints -->
< endpoint name ="Proto.Server.Endpoint"
address ="net.tcp:\\localhost:9000"
binding ="netTcpBinding"
contract ="Proto.Common.ITaskManager"
behaviorConfiguration ="Proto.Common.EndpointBehavior" />
</ service >
</ services >
< behaviors >
< serviceBehaviors >
< behavior name ="Proto.Server.ServiceBehavior" >
<!-- To receive exception details in faults for debugging purposes, set the value below to true.
Set to false before deployment to avoid disclosing exception information -->
< serviceDebug includeExceptionDetailInFaults ="true" />
</ behavior >
</ serviceBehaviors >
< endpointBehaviors >
< behavior name ="Proto.Common.EndpointBehavior" >
< protobuf />
</ behavior >
</ endpointBehaviors >
</ behaviors >
< extensions >
< behaviorExtensions >
< add name ="protobuf"
type ="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=1.0.0.280, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" />
</ behaviorExtensions >
</ extensions >
</ system.serviceModel >
</ configuration >
* This source code was highlighted with Source Code Highlighter .
<? xml version ="1.0" ? >
< configuration >
< system.serviceModel >
< client >
< endpoint name ="Proto.Client.Endpoint"
address ="net.tcp:\\localhost:9000"
binding ="netTcpBinding"
contract ="Proto.Common.ITaskManager"
behaviorConfiguration ="Proto.Common.EndpointBehavior" />
</ client >
< behaviors >
< endpointBehaviors >
< behavior name ="Proto.Common.EndpointBehavior" >
< protobuf />
</ behavior >
</ endpointBehaviors >
</ behaviors >
< extensions >
< behaviorExtensions >
< add name ="protobuf"
type ="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=1.0.0.280, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" />
</ behaviorExtensions >
</ extensions >
</ system.serviceModel >
</ configuration >
* This source code was highlighted with Source Code Highlighter .
< MessageLogTraceRecord Time ="2011-05-12T16:17:03.2780000+04:00" Source ="TransportSend" Type ="System.ServiceModel.Dispatcher.OperationFormatter+OperationFormatterMessage" xmlns ="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace" >
< s:Envelope xmlns:s ="http://www.w3.org/2003/05/soap-envelope" xmlns:a ="http://www.w3.org/2005/08/addressing" >
< s:Header >
< a:Action s:mustUnderstand ="1" >
tempuri.org/ITaskManager/GetTasksResponse
</ a:Action >
< a:RelatesTo >
urn:uuid:768e2f40-612c-4593-8cfb-eacb7b291a9c
</ a:RelatesTo >
< a:To s:mustUnderstand ="1" >
www.w3.org/2005/08/addressing/anonymous
</ a:To >
</ s:Header >
< s:Body >
< GetTasksResponse xmlns ="http://tempuri.org/" >
< proto >
Ci4IARIJCPTs+c/8SxAEGgpTdGV2ZSBKb2JzIAIqEUludmVudCBuZXcgaVBob25lCi8IAhIJCPTclY/4SxAEGg1TdGV2ZSBCYWxsbWVyKhFJbnN0YWxsIG93biBTa3lwZQ==
</ proto >
</ GetTasksResponse >
</ s:Body >
</ s:Envelope >
</ MessageLogTraceRecord >
* This source code was highlighted with Source Code Highlighter .
Source: https://habr.com/ru/post/119510/
All Articles