Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. namespace WcfEchoService
  2. {
  3. // NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
  4. [ServiceContract]
  5. public interface IEchoService
  6. {
  7.  
  8. [OperationContract, ProtoBehavior]
  9. string Echo(string value);
  10.  
  11. [OperationContract, ProtoBehavior]
  12. string EchoNull();
  13.  
  14. [OperationContract, ProtoBehavior]
  15. CompositeType[] EchoData(CompositeType[] value);
  16. }
  17.  
  18.  
  19. // Use a data contract as illustrated in the sample below to add composite types to service operations.
  20. [DataContract]
  21. [ProtoContract]
  22. public class CompositeType
  23. {
  24.  
  25.  
  26. [ProtoMember(1)]
  27. public bool BoolValue
  28. {
  29. get;
  30. set;
  31. }
  32. [ProtoMember(2)]
  33. public string StringValue
  34. {
  35. get;
  36. set;
  37. }
  38. }
  39. }
  40.  
  41. #region IEchoService Members
  42.  
  43. public EchoServiceClient() : base(new HttpBasicTransport("my service URI"))
  44. {
  45.  
  46. }
  47.  
  48. public string Echo(string value)
  49. {
  50. return (string)this.Invoke("Echo", value);
  51. }
  52.  
  53. public string EchoNull()
  54. {
  55. return (string)this.Invoke("EchoNull");
  56. }
  57.  
  58. public CompositeType[] EchoData(CompositeType[] value)
  59. {
  60. return (CompositeType[])this.Invoke("EchoData", value);
  61. }
  62.  
  63. #endregion
  64. }
  65.  
  66. class Program
  67. {
  68. static void Main(string[] args)
  69. {
  70. EchoServiceClient client = new EchoServiceClient();
  71. Console.WriteLine(client.EchoNull());
  72. }
  73. }
Add Comment
Please, Sign In to add comment