Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ServiceTest {
- [ServiceContract]
- public interface IService1 {
- [OperationContract]
- string GetData(int value);
- [OperationContract]
- CompositeType GetDataUsingDataContract(CompositeType composite);
- }
- [DataContract]
- public class CompositeType {
- bool boolValue = true;
- string stringValue = "Hello ";
- [DataMember]
- public bool BoolValue {
- get { return boolValue; }
- set { boolValue = value; }
- }
- [DataMember]
- public string StringValue {
- get { return stringValue; }
- set { stringValue = value; }
- }
- }
- namespace ServiceTest {
- public class Service1 : IService1 {
- public string GetData(int value) {
- return string.Format("You entered: {0}", value);
- }
- public CompositeType GetDataUsingDataContract(CompositeType composite) {
- if (composite == null) {
- throw new ArgumentNullException("composite");
- }
- if (composite.BoolValue) {
- composite.StringValue += "Suffix";
- }
- return composite;
- }
- }
- <configuration>
- <appSettings>
- <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
- </appSettings>
- <system.web>
- <compilation debug="true" targetFramework="4.6.1"/>
- <httpRuntime targetFramework="4.6.1"/>
- <httpModules>
- <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
- </httpModules>
- </system.web>
- <system.serviceModel>
- <behaviors>
- <serviceBehaviors>
- <behavior>
- <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
- <serviceDebug includeExceptionDetailInFaults="false"/>
- </behavior>
- </serviceBehaviors>
- </behaviors>
- <protocolMapping>
- <add binding="basicHttpsBinding" scheme="https"/>
- </protocolMapping>
- <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
- </system.serviceModel>
- <system.webServer>
- <modules runAllManagedModulesForAllRequests="true">
- <remove name="ApplicationInsightsWebTracking"/>
- <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
- preCondition="managedHandler"/>
- </modules>
- <directoryBrowse enabled="true"/>
- <validation validateIntegratedModeConfiguration="false"/>
- </system.webServer>
- </configuration>
- namespace ClientServiceTest {
- class Program {
- static void Main(string[] args) {
- Service1Client client = new Service1Client();
- DateTime begin = DateTime.Now;
- string res = client.GetData(0);
- TimeSpan interval = DateTime.Now - begin;
- ;
- }
- }
Add Comment
Please, Sign In to add comment