Add a client for the .NET implementation
This commit is contained in:
parent
e01cbdb5ac
commit
8ab7a708d6
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,166 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
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<RankingServiceReference.Competitor[]> 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>, RankingServiceReference.IRankingService
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implement this partial method to configure the service endpoint.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceEndpoint">The endpoint to configure</param>
|
||||||
|
/// <param name="clientCredentials">The client credentials</param>
|
||||||
|
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<RankingServiceReference.Competitor[]> 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.IAsyncResult>(((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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
Tasks/Lab7/NetRankingClient/NetRankingClient.csproj
Normal file
18
Tasks/Lab7/NetRankingClient/NetRankingClient.csproj
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.ServiceModel.Duplex" Version="6.0.*" />
|
||||||
|
<PackageReference Include="System.ServiceModel.Federation" Version="6.0.*" />
|
||||||
|
<PackageReference Include="System.ServiceModel.Http" Version="6.0.*" />
|
||||||
|
<PackageReference Include="System.ServiceModel.NetTcp" Version="6.0.*" />
|
||||||
|
<PackageReference Include="System.ServiceModel.Security" Version="6.0.*" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
25
Tasks/Lab7/NetRankingClient/NetRankingClient.sln
Normal file
25
Tasks/Lab7/NetRankingClient/NetRankingClient.sln
Normal file
|
@ -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
|
10
Tasks/Lab7/NetRankingClient/Program.cs
Normal file
10
Tasks/Lab7/NetRankingClient/Program.cs
Normal file
|
@ -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}");
|
||||||
|
}
|
Loading…
Reference in a new issue