diff --git a/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/ConnectedService.json b/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/ConnectedService.json new file mode 100644 index 0000000..60c3057 --- /dev/null +++ b/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/ConnectedService.json @@ -0,0 +1,17 @@ +{ + "ExtendedData": { + "inputs": [ + "https://localhost:5001/RankingService/WSHttps" + ], + "collectionTypes": [ + "System.Array", + "System.Collections.Generic.Dictionary`2" + ], + "namespaceMappings": [ + "*, RankingServiceReference" + ], + "sync": true, + "targetFramework": "net8.0", + "typeReuseMode": "All" + } +} \ No newline at end of file diff --git a/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/Reference.cs b/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/Reference.cs new file mode 100644 index 0000000..ca6cd82 --- /dev/null +++ b/Tasks/Lab7/NetRankingClient/Connected Services/RankingServiceReference/Reference.cs @@ -0,0 +1,166 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RankingServiceReference +{ + using System.Runtime.Serialization; + + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="Competitor", Namespace="http://schemas.datacontract.org/2004/07/RankingServer")] + public partial class Competitor : object + { + + private string NameField; + + private string TimeField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Name + { + get + { + return this.NameField; + } + set + { + this.NameField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Time + { + get + { + return this.TimeField; + } + set + { + this.TimeField = value; + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="RankingServiceReference.IRankingService")] + public interface IRankingService + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRankingService/RankingList", ReplyAction="http://tempuri.org/IRankingService/RankingListResponse")] + RankingServiceReference.Competitor[] RankingList(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRankingService/RankingList", ReplyAction="http://tempuri.org/IRankingService/RankingListResponse")] + System.Threading.Tasks.Task RankingListAsync(); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public interface IRankingServiceChannel : RankingServiceReference.IRankingService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public partial class RankingServiceClient : System.ServiceModel.ClientBase, RankingServiceReference.IRankingService + { + + /// + /// Implement this partial method to configure the service endpoint. + /// + /// The endpoint to configure + /// The client credentials + static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials); + + public RankingServiceClient(EndpointConfiguration endpointConfiguration) : + base(RankingServiceClient.GetBindingForEndpoint(endpointConfiguration), RankingServiceClient.GetEndpointAddress(endpointConfiguration)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public RankingServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) : + base(RankingServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public RankingServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : + base(RankingServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public RankingServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public RankingServiceReference.Competitor[] RankingList() + { + return base.Channel.RankingList(); + } + + public System.Threading.Tasks.Task RankingListAsync() + { + return base.Channel.RankingListAsync(); + } + + public virtual System.Threading.Tasks.Task OpenAsync() + { + return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen)); + } + + private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IRankingService)) + { + System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(); + result.MaxBufferSize = int.MaxValue; + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; + result.MaxReceivedMessageSize = int.MaxValue; + result.AllowCookies = true; + return result; + } + if ((endpointConfiguration == EndpointConfiguration.WSHttpBinding_IRankingService)) + { + System.ServiceModel.WSHttpBinding result = new System.ServiceModel.WSHttpBinding(); + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; + result.MaxReceivedMessageSize = int.MaxValue; + result.AllowCookies = true; + result.Security.Mode = System.ServiceModel.SecurityMode.Transport; + return result; + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IRankingService)) + { + return new System.ServiceModel.EndpointAddress("http://127.0.0.1:5000/RankingService/basichttp"); + } + if ((endpointConfiguration == EndpointConfiguration.WSHttpBinding_IRankingService)) + { + return new System.ServiceModel.EndpointAddress("https://127.0.0.1:5001/RankingService/WSHttps"); + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + public enum EndpointConfiguration + { + + BasicHttpBinding_IRankingService, + + WSHttpBinding_IRankingService, + } + } +} diff --git a/Tasks/Lab7/NetRankingClient/NetRankingClient.csproj b/Tasks/Lab7/NetRankingClient/NetRankingClient.csproj new file mode 100644 index 0000000..4a48f1a --- /dev/null +++ b/Tasks/Lab7/NetRankingClient/NetRankingClient.csproj @@ -0,0 +1,18 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + diff --git a/Tasks/Lab7/NetRankingClient/NetRankingClient.sln b/Tasks/Lab7/NetRankingClient/NetRankingClient.sln new file mode 100644 index 0000000..a44026a --- /dev/null +++ b/Tasks/Lab7/NetRankingClient/NetRankingClient.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetRankingClient", "NetRankingClient.csproj", "{05DBF92A-0F83-422D-B75C-92D63E401F4D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {05DBF92A-0F83-422D-B75C-92D63E401F4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {05DBF92A-0F83-422D-B75C-92D63E401F4D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05DBF92A-0F83-422D-B75C-92D63E401F4D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {05DBF92A-0F83-422D-B75C-92D63E401F4D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3DE92BFA-0937-467E-BADD-698CFF7D177D} + EndGlobalSection +EndGlobal diff --git a/Tasks/Lab7/NetRankingClient/Program.cs b/Tasks/Lab7/NetRankingClient/Program.cs new file mode 100644 index 0000000..4021907 --- /dev/null +++ b/Tasks/Lab7/NetRankingClient/Program.cs @@ -0,0 +1,10 @@ +// See https://aka.ms/new-console-template for more information +using RankingServiceReference; + +RankingServiceClient client = new(RankingServiceClient.EndpointConfiguration.BasicHttpBinding_IRankingService); +Competitor[] competitors = client.RankingList(); + +for (int i = 0; i < competitors.Length; i++) +{ + Console.WriteLine($"{i + 1}. {competitors[i].Name}, {competitors[i].Time}"); +}