Guest User

Untitled

a guest
Jan 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. namespace ServiceTest {
  2.  
  3. [ServiceContract]
  4. public interface IService1 {
  5.  
  6. [OperationContract]
  7. string GetData(int value);
  8.  
  9. [OperationContract]
  10. CompositeType GetDataUsingDataContract(CompositeType composite);
  11.  
  12. }
  13.  
  14. [DataContract]
  15. public class CompositeType {
  16. bool boolValue = true;
  17. string stringValue = "Hello ";
  18.  
  19. [DataMember]
  20. public bool BoolValue {
  21. get { return boolValue; }
  22. set { boolValue = value; }
  23. }
  24.  
  25. [DataMember]
  26. public string StringValue {
  27. get { return stringValue; }
  28. set { stringValue = value; }
  29. }
  30. }
  31.  
  32. namespace ServiceTest {
  33. public class Service1 : IService1 {
  34. public string GetData(int value) {
  35. return string.Format("You entered: {0}", value);
  36. }
  37.  
  38. public CompositeType GetDataUsingDataContract(CompositeType composite) {
  39. if (composite == null) {
  40. throw new ArgumentNullException("composite");
  41. }
  42. if (composite.BoolValue) {
  43. composite.StringValue += "Suffix";
  44. }
  45. return composite;
  46. }
  47. }
  48.  
  49. <configuration>
  50. <appSettings>
  51. <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  52. </appSettings>
  53. <system.web>
  54. <compilation debug="true" targetFramework="4.6.1"/>
  55. <httpRuntime targetFramework="4.6.1"/>
  56. <httpModules>
  57. <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
  58. </httpModules>
  59. </system.web>
  60. <system.serviceModel>
  61. <behaviors>
  62. <serviceBehaviors>
  63. <behavior>
  64. <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
  65. <serviceDebug includeExceptionDetailInFaults="false"/>
  66. </behavior>
  67. </serviceBehaviors>
  68. </behaviors>
  69. <protocolMapping>
  70. <add binding="basicHttpsBinding" scheme="https"/>
  71. </protocolMapping>
  72. <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  73. </system.serviceModel>
  74. <system.webServer>
  75. <modules runAllManagedModulesForAllRequests="true">
  76. <remove name="ApplicationInsightsWebTracking"/>
  77. <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
  78. preCondition="managedHandler"/>
  79. </modules>
  80. <directoryBrowse enabled="true"/>
  81. <validation validateIntegratedModeConfiguration="false"/>
  82. </system.webServer>
  83. </configuration>
  84.  
  85. namespace ClientServiceTest {
  86. class Program {
  87. static void Main(string[] args) {
  88. Service1Client client = new Service1Client();
  89. DateTime begin = DateTime.Now;
  90. string res = client.GetData(0);
  91. TimeSpan interval = DateTime.Now - begin;
  92. ;
  93. }
  94. }
Add Comment
Please, Sign In to add comment