Create a client for the ranking service

This commit is contained in:
Manuel Thalmann 2024-06-06 14:09:50 +02:00
parent 175fbc4a8c
commit d3e98b0dbe
5 changed files with 318 additions and 0 deletions

View file

@ -0,0 +1,45 @@
{
"ExtendedData": {
"inputs": [
"http://localhost:8081/ranking/RankingService?wsdl"
],
"collectionTypes": [
"System.Array",
"System.Collections.Generic.Dictionary`2"
],
"namespaceMappings": [
"*, RankingServiceReference"
],
"references": [
"Microsoft.Extensions.ObjectPool, {Microsoft.Extensions.ObjectPool, 6.0.16}",
"Microsoft.IdentityModel.Logging, {Microsoft.IdentityModel.Logging, 6.8.0}",
"Microsoft.IdentityModel.Protocols.WsTrust, {Microsoft.IdentityModel.Protocols.WsTrust, 6.8.0}",
"Microsoft.IdentityModel.Tokens, {Microsoft.IdentityModel.Tokens, 6.8.0}",
"Microsoft.IdentityModel.Tokens.Saml, {Microsoft.IdentityModel.Tokens.Saml, 6.8.0}",
"Microsoft.IdentityModel.Xml, {Microsoft.IdentityModel.Xml, 6.8.0}",
"System.Formats.Asn1, {System.Formats.Asn1, 6.0.0}",
"System.IO, {System.IO, 4.3.0}",
"System.Reflection.DispatchProxy, {System.Reflection.DispatchProxy, 4.7.1}",
"System.Runtime, {System.Runtime, 4.3.0}",
"System.Security.AccessControl, {System.Security.AccessControl, 6.0.0}",
"System.Security.Cryptography.Cng, {System.Security.Cryptography.Cng, 4.5.0}",
"System.Security.Cryptography.Pkcs, {System.Security.Cryptography.Pkcs, 6.0.1}",
"System.Security.Cryptography.Xml, {System.Security.Cryptography.Xml, 6.0.1}",
"System.Security.Principal.Windows, {System.Security.Principal.Windows, 5.0.0}",
"System.ServiceModel.Duplex, {System.ServiceModel.Duplex, 6.0.0}",
"System.ServiceModel.Federation, {System.ServiceModel.Federation, 6.0.0}",
"System.ServiceModel.Http, {System.ServiceModel.Http, 6.0.0}",
"System.ServiceModel.NetFramingBase, {System.ServiceModel.NetFramingBase, 6.0.0}",
"System.ServiceModel.NetTcp, {System.ServiceModel.NetTcp, 6.0.0}",
"System.ServiceModel.Primitives, {System.ServiceModel.Primitives, 6.0.0}",
"System.ServiceModel.Security, {System.ServiceModel.Security, 6.0.0}",
"System.Text.Encoding, {System.Text.Encoding, 4.3.0}",
"System.Threading.Tasks, {System.Threading.Tasks, 4.3.0}",
"System.Xml.ReaderWriter, {System.Xml.ReaderWriter, 4.3.0}",
"System.Xml.XmlDocument, {System.Xml.XmlDocument, 4.3.0}"
],
"sync": true,
"targetFramework": "net8.0",
"typeReuseMode": "All"
}
}

View file

@ -0,0 +1,222 @@
//------------------------------------------------------------------------------
// <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
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
[System.ServiceModel.ServiceContractAttribute(Namespace="http://ranking/", ConfigurationName="RankingServiceReference.RankingService")]
public interface RankingService
{
// CODEGEN: Parameter 'return' requires additional schema information that cannot be captured using the parameter mode. The specific attribute is 'Microsoft.Xml.Serialization.XmlArrayAttribute'.
[System.ServiceModel.OperationContractAttribute(Action="http://ranking/RankingService/rankingListRequest", ReplyAction="http://ranking/RankingService/rankingListResponse")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
[return: System.ServiceModel.MessageParameterAttribute(Name="return")]
RankingServiceReference.rankingListResponse rankingList(RankingServiceReference.rankingListRequest request);
[System.ServiceModel.OperationContractAttribute(Action="http://ranking/RankingService/rankingListRequest", ReplyAction="http://ranking/RankingService/rankingListResponse")]
System.Threading.Tasks.Task<RankingServiceReference.rankingListResponse> rankingListAsync(RankingServiceReference.rankingListRequest request);
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://ranking/")]
public partial class competitor
{
private string nameField;
private string timeField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
public string time
{
get
{
return this.timeField;
}
set
{
this.timeField = value;
}
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="rankingList", WrapperNamespace="http://ranking/", IsWrapped=true)]
public partial class rankingListRequest
{
public rankingListRequest()
{
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName="rankingListResponse", WrapperNamespace="http://ranking/", IsWrapped=true)]
public partial class rankingListResponse
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace="", Order=0)]
[System.Xml.Serialization.XmlArrayAttribute()]
[System.Xml.Serialization.XmlArrayItemAttribute("item", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public RankingServiceReference.competitor[] @return;
public rankingListResponse()
{
}
public rankingListResponse(RankingServiceReference.competitor[] @return)
{
this.@return = @return;
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")]
public interface RankingServiceChannel : RankingServiceReference.RankingService, 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.RankingService>, RankingServiceReference.RankingService
{
/// <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() :
base(RankingServiceClient.GetDefaultBinding(), RankingServiceClient.GetDefaultEndpointAddress())
{
this.Endpoint.Name = EndpointConfiguration.RankingServicePort.ToString();
ConfigureEndpoint(this.Endpoint, this.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)
{
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
RankingServiceReference.rankingListResponse RankingServiceReference.RankingService.rankingList(RankingServiceReference.rankingListRequest request)
{
return base.Channel.rankingList(request);
}
public RankingServiceReference.competitor[] rankingList()
{
RankingServiceReference.rankingListRequest inValue = new RankingServiceReference.rankingListRequest();
RankingServiceReference.rankingListResponse retVal = ((RankingServiceReference.RankingService)(this)).rankingList(inValue);
return retVal.@return;
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<RankingServiceReference.rankingListResponse> RankingServiceReference.RankingService.rankingListAsync(RankingServiceReference.rankingListRequest request)
{
return base.Channel.rankingListAsync(request);
}
public System.Threading.Tasks.Task<RankingServiceReference.rankingListResponse> rankingListAsync()
{
RankingServiceReference.rankingListRequest inValue = new RankingServiceReference.rankingListRequest();
return ((RankingServiceReference.RankingService)(this)).rankingListAsync(inValue);
}
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.RankingServicePort))
{
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;
}
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.RankingServicePort))
{
return new System.ServiceModel.EndpointAddress("http://localhost:8081/ranking/RankingService");
}
throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
}
private static System.ServiceModel.Channels.Binding GetDefaultBinding()
{
return RankingServiceClient.GetBindingForEndpoint(EndpointConfiguration.RankingServicePort);
}
private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
{
return RankingServiceClient.GetEndpointAddress(EndpointConfiguration.RankingServicePort);
}
public enum EndpointConfiguration
{
RankingServicePort,
}
}
}

View file

@ -0,0 +1,8 @@
// See https://aka.ms/new-console-template for more information
RankingServiceReference.RankingServiceClient client = new RankingServiceReference.RankingServiceClient(RankingServiceReference.RankingServiceClient.EndpointConfiguration.RankingServicePort);
RankingServiceReference.competitor[] competitors = client.rankingList();
for (int i = 0; i < competitors.Length; i++)
{
Console.WriteLine($"{i + 1}. {competitors[i].name}, {competitors[i].time}");
}

View 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>

View 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}") = "RankingClient", "RankingClient.csproj", "{1F5101DA-36BF-4B94-811A-10BC0D85DB3D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1F5101DA-36BF-4B94-811A-10BC0D85DB3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F5101DA-36BF-4B94-811A-10BC0D85DB3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F5101DA-36BF-4B94-811A-10BC0D85DB3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F5101DA-36BF-4B94-811A-10BC0D85DB3D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A04AF648-3A85-4288-B4CC-24BC3416ABE6}
EndGlobalSection
EndGlobal