Compare commits
4 commits
1e8654968e
...
8ab7a708d6
Author | SHA1 | Date | |
---|---|---|---|
8ab7a708d6 | |||
e01cbdb5ac | |||
d3e98b0dbe | |||
175fbc4a8c |
20 changed files with 738 additions and 0 deletions
BIN
Tasks/Lab7/DT7.pdf
Normal file
BIN
Tasks/Lab7/DT7.pdf
Normal file
Binary file not shown.
|
@ -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}");
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
8
Tasks/Lab7/RankingClient/Program.cs
Normal file
8
Tasks/Lab7/RankingClient/Program.cs
Normal 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}");
|
||||
}
|
18
Tasks/Lab7/RankingClient/RankingClient.csproj
Normal file
18
Tasks/Lab7/RankingClient/RankingClient.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/RankingClient/RankingClient.sln
Normal file
25
Tasks/Lab7/RankingClient/RankingClient.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}") = "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
|
BIN
Tasks/Lab7/RankingServer.jar
Normal file
BIN
Tasks/Lab7/RankingServer.jar
Normal file
Binary file not shown.
14
Tasks/Lab7/RankingServer/Competitor.cs
Normal file
14
Tasks/Lab7/RankingServer/Competitor.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Runtime.Serialization;
|
||||
|
||||
namespace RankingServer
|
||||
{
|
||||
[DataContract]
|
||||
public class Competitor
|
||||
{
|
||||
[DataMember]
|
||||
public string? Name { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string? Time { get; set; }
|
||||
}
|
||||
}
|
11
Tasks/Lab7/RankingServer/IRankingService.cs
Normal file
11
Tasks/Lab7/RankingServer/IRankingService.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using CoreWCF;
|
||||
|
||||
namespace RankingServer
|
||||
{
|
||||
[ServiceContract]
|
||||
public interface IRankingService
|
||||
{
|
||||
[OperationContract]
|
||||
List<Competitor> RankingList();
|
||||
}
|
||||
}
|
49
Tasks/Lab7/RankingServer/Program.cs
Normal file
49
Tasks/Lab7/RankingServer/Program.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
using RankingServer;
|
||||
using CoreWCF.Configuration;
|
||||
using CoreWCF.Description;
|
||||
using CoreWCF;
|
||||
using System.Net;
|
||||
|
||||
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.WebHost
|
||||
.ConfigureKestrel(
|
||||
(context, options) =>
|
||||
{
|
||||
options.AllowSynchronousIO = true;
|
||||
})
|
||||
.UseKestrel(
|
||||
(context, options) =>
|
||||
{
|
||||
options.Listen(IPAddress.Loopback, 5000);
|
||||
options.Listen(
|
||||
IPAddress.Loopback,
|
||||
5001,
|
||||
listenOptions =>
|
||||
{
|
||||
listenOptions.UseHttps();
|
||||
});
|
||||
});
|
||||
|
||||
// Add support
|
||||
builder.Services.AddServiceModelServices().AddServiceModelMetadata();
|
||||
builder.Services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddAuthentication();
|
||||
|
||||
WebApplication app = builder.Build();
|
||||
|
||||
app.UseServiceModel(
|
||||
builder =>
|
||||
{
|
||||
builder
|
||||
.AddService<RankingService>((serviceOptions) => { })
|
||||
.AddServiceEndpoint<RankingService, IRankingService>(new BasicHttpBinding(), "/RankingService/basichttp")
|
||||
.AddServiceEndpoint<RankingService, IRankingService>(new WSHttpBinding(SecurityMode.Transport), "/RankingService/WSHttps");
|
||||
});
|
||||
|
||||
ServiceMetadataBehavior serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
|
||||
serviceMetadataBehavior.HttpGetEnabled = true;
|
||||
app.Logger.LogInformation("Starting Ranking Service…");
|
||||
app.Run();
|
10
Tasks/Lab7/RankingServer/Properties/appsettings.json
Normal file
10
Tasks/Lab7/RankingServer/Properties/appsettings.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"CoreWCF.Channels": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
12
Tasks/Lab7/RankingServer/Properties/launchSettings.json
Normal file
12
Tasks/Lab7/RankingServer/Properties/launchSettings.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"profiles": {
|
||||
"RankingServer": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:59129;http://localhost:59130"
|
||||
}
|
||||
}
|
||||
}
|
15
Tasks/Lab7/RankingServer/RankingServer.csproj
Normal file
15
Tasks/Lab7/RankingServer/RankingServer.csproj
Normal file
|
@ -0,0 +1,15 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CoreWCF.Http" Version="1.5.2" />
|
||||
<PackageReference Include="CoreWCF.Primitives" Version="1.5.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
25
Tasks/Lab7/RankingServer/RankingServer.sln
Normal file
25
Tasks/Lab7/RankingServer/RankingServer.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}") = "RankingServer", "RankingServer.csproj", "{81FE59F3-371E-4E80-A2C8-C93E03774EE9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{81FE59F3-371E-4E80-A2C8-C93E03774EE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{81FE59F3-371E-4E80-A2C8-C93E03774EE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{81FE59F3-371E-4E80-A2C8-C93E03774EE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{81FE59F3-371E-4E80-A2C8-C93E03774EE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3B55BFCE-E49B-4594-B364-4CF5D7D70E92}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
48
Tasks/Lab7/RankingServer/RankingService.cs
Normal file
48
Tasks/Lab7/RankingServer/RankingService.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
namespace RankingServer
|
||||
{
|
||||
public class RankingService : IRankingService
|
||||
{
|
||||
private string[] ranks = {
|
||||
"Mueller Stefan,02:31:14",
|
||||
"Marti Adrian,2:30:09",
|
||||
"Kiptum Daniel,2:11:31",
|
||||
"Ancay Tarcis,2:20:02",
|
||||
"Kreibuhl Christian,2:21:47",
|
||||
"Ott Michael,2:33:48",
|
||||
"Menzi Christoph,2:27:26",
|
||||
"Oliver Ruben,2:32:12",
|
||||
"Elmer Beat,2:33:53",
|
||||
"Kuehni Martin,2:33:36"
|
||||
};
|
||||
|
||||
private Lazy<List<Competitor>> competitors;
|
||||
|
||||
public RankingService()
|
||||
{
|
||||
competitors = new Lazy<List<Competitor>>(
|
||||
() =>
|
||||
{
|
||||
List<Competitor> ranklingList = new List<Competitor>();
|
||||
foreach (string rank in ranks)
|
||||
{
|
||||
string[] fields = rank.Split(',');
|
||||
|
||||
Competitor competitor = new()
|
||||
{
|
||||
Name = fields[0],
|
||||
Time = fields[1]
|
||||
};
|
||||
|
||||
ranklingList.Add(competitor);
|
||||
};
|
||||
return ranklingList;
|
||||
});
|
||||
}
|
||||
|
||||
public List<Competitor> RankingList()
|
||||
{
|
||||
return competitors.Value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue