diff --git a/samples/Models/ComplexModelInput.cs b/samples/Models/ComplexModelInput.cs index 403e608d..b6e7727f 100644 --- a/samples/Models/ComplexModelInput.cs +++ b/samples/Models/ComplexModelInput.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; +using System.ServiceModel; namespace Models { @@ -21,6 +22,19 @@ public class ComplexModelInput [DataMember] public List ComplexListProperty { get; set; } + + [DataMember] + public List DerivedObjects { get; set; } + + [DataContract] + [ServiceKnownType(typeof(DerivedObject))] + public class DerivedObject : BaseObject + { + public DerivedObject() + { + Name = nameof(DerivedObject); + } + } } [DataContract] @@ -32,4 +46,10 @@ public class ComplexObject [DataMember] public int IntProperty { get; set; } } + + [DataContract] + public class BaseObject + { + public string Name { get; set; } = nameof(BaseObject); + } } diff --git a/samples/Sample.sln b/samples/Sample.sln index 5d3921c3..cfff8cec 100644 --- a/samples/Sample.sln +++ b/samples/Sample.sln @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SoapCore", "..\src\SoapCore EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{DFF0AC9A-391D-475D-BDE7-F54271C39886}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceReferenceClient", "ServiceReferenceClient\ServiceReferenceClient.csproj", "{B68A055C-6B71-4D2D-B663-6111753A0DA1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {DFF0AC9A-391D-475D-BDE7-F54271C39886}.Debug|Any CPU.Build.0 = Debug|Any CPU {DFF0AC9A-391D-475D-BDE7-F54271C39886}.Release|Any CPU.ActiveCfg = Release|Any CPU {DFF0AC9A-391D-475D-BDE7-F54271C39886}.Release|Any CPU.Build.0 = Release|Any CPU + {B68A055C-6B71-4D2D-B663-6111753A0DA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B68A055C-6B71-4D2D-B663-6111753A0DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B68A055C-6B71-4D2D-B663-6111753A0DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B68A055C-6B71-4D2D-B663-6111753A0DA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/ServiceReferenceClient/Connected Services/ServiceReference/ConnectedService.json b/samples/ServiceReferenceClient/Connected Services/ServiceReference/ConnectedService.json new file mode 100644 index 00000000..08144bee --- /dev/null +++ b/samples/ServiceReferenceClient/Connected Services/ServiceReference/ConnectedService.json @@ -0,0 +1,45 @@ +{ + "ExtendedData": { + "inputs": [ + "http://localhost:5050/Service.svc" + ], + "collectionTypes": [ + "System.Array", + "System.Collections.Generic.Dictionary`2" + ], + "namespaceMappings": [ + "*, ServiceReference" + ], + "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" + } +} \ No newline at end of file diff --git a/samples/ServiceReferenceClient/Connected Services/ServiceReference/Reference.cs b/samples/ServiceReferenceClient/Connected Services/ServiceReference/Reference.cs new file mode 100644 index 00000000..aae33bbd --- /dev/null +++ b/samples/ServiceReferenceClient/Connected Services/ServiceReference/Reference.cs @@ -0,0 +1,525 @@ +//------------------------------------------------------------------------------ +// +// 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 ServiceReference +{ + 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="ComplexModelInput", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public partial class ComplexModelInput : object + { + + private ServiceReference.ComplexObject[] ComplexListPropertyField; + + private System.DateTimeOffset DateTimeOffsetPropertyField; + + private ServiceReference.BaseObject[] DerivedObjectsField; + + private int IntPropertyField; + + private string[] ListPropertyField; + + private string StringPropertyField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public ServiceReference.ComplexObject[] ComplexListProperty + { + get + { + return this.ComplexListPropertyField; + } + set + { + this.ComplexListPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public System.DateTimeOffset DateTimeOffsetProperty + { + get + { + return this.DateTimeOffsetPropertyField; + } + set + { + this.DateTimeOffsetPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public ServiceReference.BaseObject[] DerivedObjects + { + get + { + return this.DerivedObjectsField; + } + set + { + this.DerivedObjectsField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public int IntProperty + { + get + { + return this.IntPropertyField; + } + set + { + this.IntPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string[] ListProperty + { + get + { + return this.ListPropertyField; + } + set + { + this.ListPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StringProperty + { + get + { + return this.StringPropertyField; + } + set + { + this.StringPropertyField = value; + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="ComplexObject", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public partial class ComplexObject : object + { + + private int IntPropertyField; + + private string StringPropertyField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public int IntProperty + { + get + { + return this.IntPropertyField; + } + set + { + this.IntPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StringProperty + { + get + { + return this.StringPropertyField; + } + set + { + this.StringPropertyField = value; + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="BaseObject", Namespace="http://schemas.datacontract.org/2004/07/Models")] + [System.Runtime.Serialization.KnownTypeAttribute(typeof(ServiceReference.DerivedObject))] + public partial class BaseObject : object + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="DerivedObject", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public partial class DerivedObject : ServiceReference.BaseObject + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="ComplexModelResponse", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public partial class ComplexModelResponse : object + { + + private System.DateTimeOffset DateTimeOffsetPropertyField; + + private float FloatPropertyField; + + private string[] ListPropertyField; + + private string StringPropertyField; + + private ServiceReference.TestEnum TestEnumField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public System.DateTimeOffset DateTimeOffsetProperty + { + get + { + return this.DateTimeOffsetPropertyField; + } + set + { + this.DateTimeOffsetPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public float FloatProperty + { + get + { + return this.FloatPropertyField; + } + set + { + this.FloatPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string[] ListProperty + { + get + { + return this.ListPropertyField; + } + set + { + this.ListPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StringProperty + { + get + { + return this.StringPropertyField; + } + set + { + this.StringPropertyField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)] + public ServiceReference.TestEnum TestEnum + { + get + { + return this.TestEnumField; + } + set + { + this.TestEnumField = value; + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="TestEnum", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public enum TestEnum : int + { + + [System.Runtime.Serialization.EnumMemberAttribute()] + One = 0, + + [System.Runtime.Serialization.EnumMemberAttribute()] + Two = 1, + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.Runtime.Serialization.DataContractAttribute(Name="ComplexReturnModel", Namespace="http://schemas.datacontract.org/2004/07/Models")] + public partial class ComplexReturnModel : object + { + + private int IdField; + + private string NameField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public int Id + { + get + { + return this.IdField; + } + set + { + this.IdField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Name + { + get + { + return this.NameField; + } + set + { + this.NameField = value; + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference.ISampleService")] + public interface ISampleService + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/Ping", ReplyAction="http://tempuri.org/ISampleService/PingResponse")] + string Ping(string s); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/Ping", ReplyAction="http://tempuri.org/ISampleService/PingResponse")] + System.Threading.Tasks.Task PingAsync(string s); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/PingComplexModel", ReplyAction="http://tempuri.org/ISampleService/PingComplexModelResponse")] + ServiceReference.ComplexModelResponse PingComplexModel(ServiceReference.ComplexModelInput inputModel); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/PingComplexModel", ReplyAction="http://tempuri.org/ISampleService/PingComplexModelResponse")] + System.Threading.Tasks.Task PingComplexModelAsync(ServiceReference.ComplexModelInput inputModel); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/IntArray", ReplyAction="http://tempuri.org/ISampleService/IntArrayResponse")] + int[] IntArray(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/IntArray", ReplyAction="http://tempuri.org/ISampleService/IntArrayResponse")] + System.Threading.Tasks.Task IntArrayAsync(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/ComplexReturnModel", ReplyAction="http://tempuri.org/ISampleService/ComplexReturnModelResponse")] + ServiceReference.ComplexReturnModel[] ComplexReturnModel(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/ComplexReturnModel", ReplyAction="http://tempuri.org/ISampleService/ComplexReturnModelResponse")] + System.Threading.Tasks.Task ComplexReturnModelAsync(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/VoidMethod", ReplyAction="http://tempuri.org/ISampleService/VoidMethodResponse")] + [return: System.ServiceModel.MessageParameterAttribute(Name="s")] + string VoidMethod(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/VoidMethod", ReplyAction="http://tempuri.org/ISampleService/VoidMethodResponse")] + [return: System.ServiceModel.MessageParameterAttribute(Name="s")] + System.Threading.Tasks.Task VoidMethodAsync(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/AsyncMethod", ReplyAction="http://tempuri.org/ISampleService/AsyncMethodResponse")] + int AsyncMethod(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/AsyncMethod", ReplyAction="http://tempuri.org/ISampleService/AsyncMethodResponse")] + System.Threading.Tasks.Task AsyncMethodAsync(); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/NullableMethod", ReplyAction="http://tempuri.org/ISampleService/NullableMethodResponse")] + System.Nullable NullableMethod(System.Nullable arg); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/NullableMethod", ReplyAction="http://tempuri.org/ISampleService/NullableMethodResponse")] + System.Threading.Tasks.Task> NullableMethodAsync(System.Nullable arg); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/XmlMethod", ReplyAction="http://tempuri.org/ISampleService/XmlMethodResponse")] + void XmlMethod(System.Xml.XmlElement xml); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleService/XmlMethod", ReplyAction="http://tempuri.org/ISampleService/XmlMethodResponse")] + System.Threading.Tasks.Task XmlMethodAsync(System.Xml.XmlElement xml); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public interface ISampleServiceChannel : ServiceReference.ISampleService, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.2.0-preview1.23462.5")] + public partial class SampleServiceClient : System.ServiceModel.ClientBase, ServiceReference.ISampleService + { + + /// + /// 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 SampleServiceClient() : + base(SampleServiceClient.GetDefaultBinding(), SampleServiceClient.GetDefaultEndpointAddress()) + { + this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_ISampleService.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public SampleServiceClient(EndpointConfiguration endpointConfiguration) : + base(SampleServiceClient.GetBindingForEndpoint(endpointConfiguration), SampleServiceClient.GetEndpointAddress(endpointConfiguration)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public SampleServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) : + base(SampleServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public SampleServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : + base(SampleServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public SampleServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public string Ping(string s) + { + return base.Channel.Ping(s); + } + + public System.Threading.Tasks.Task PingAsync(string s) + { + return base.Channel.PingAsync(s); + } + + public ServiceReference.ComplexModelResponse PingComplexModel(ServiceReference.ComplexModelInput inputModel) + { + return base.Channel.PingComplexModel(inputModel); + } + + public System.Threading.Tasks.Task PingComplexModelAsync(ServiceReference.ComplexModelInput inputModel) + { + return base.Channel.PingComplexModelAsync(inputModel); + } + + public int[] IntArray() + { + return base.Channel.IntArray(); + } + + public System.Threading.Tasks.Task IntArrayAsync() + { + return base.Channel.IntArrayAsync(); + } + + public ServiceReference.ComplexReturnModel[] ComplexReturnModel() + { + return base.Channel.ComplexReturnModel(); + } + + public System.Threading.Tasks.Task ComplexReturnModelAsync() + { + return base.Channel.ComplexReturnModelAsync(); + } + + public string VoidMethod() + { + return base.Channel.VoidMethod(); + } + + public System.Threading.Tasks.Task VoidMethodAsync() + { + return base.Channel.VoidMethodAsync(); + } + + public int AsyncMethod() + { + return base.Channel.AsyncMethod(); + } + + public System.Threading.Tasks.Task AsyncMethodAsync() + { + return base.Channel.AsyncMethodAsync(); + } + + public System.Nullable NullableMethod(System.Nullable arg) + { + return base.Channel.NullableMethod(arg); + } + + public System.Threading.Tasks.Task> NullableMethodAsync(System.Nullable arg) + { + return base.Channel.NullableMethodAsync(arg); + } + + public void XmlMethod(System.Xml.XmlElement xml) + { + base.Channel.XmlMethod(xml); + } + + public System.Threading.Tasks.Task XmlMethodAsync(System.Xml.XmlElement xml) + { + return base.Channel.XmlMethodAsync(xml); + } + + 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_ISampleService)) + { + 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.BasicHttpBinding_ISampleService)) + { + return new System.ServiceModel.EndpointAddress("http://localhost:5050/Service.svc"); + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.Channels.Binding GetDefaultBinding() + { + return SampleServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_ISampleService); + } + + private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress() + { + return SampleServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_ISampleService); + } + + public enum EndpointConfiguration + { + + BasicHttpBinding_ISampleService, + } + } +} diff --git a/samples/ServiceReferenceClient/Program.cs b/samples/ServiceReferenceClient/Program.cs new file mode 100644 index 00000000..2a4b08c6 --- /dev/null +++ b/samples/ServiceReferenceClient/Program.cs @@ -0,0 +1,4 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); + + diff --git a/samples/ServiceReferenceClient/ServiceReferenceClient.csproj b/samples/ServiceReferenceClient/ServiceReferenceClient.csproj new file mode 100644 index 00000000..4a48f1a8 --- /dev/null +++ b/samples/ServiceReferenceClient/ServiceReferenceClient.csproj @@ -0,0 +1,18 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + diff --git a/src/SoapCore/ServiceModel/ServiceDescription.cs b/src/SoapCore/ServiceModel/ServiceDescription.cs index 16d0c4ec..91309da3 100644 --- a/src/SoapCore/ServiceModel/ServiceDescription.cs +++ b/src/SoapCore/ServiceModel/ServiceDescription.cs @@ -1,4 +1,5 @@ using System; +using System.CodeDom; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -11,7 +12,14 @@ public class ServiceDescription public ServiceDescription(Type serviceType, bool generateSoapActionWithoutContractName) { ServiceType = serviceType; - ServiceKnownTypes = serviceType.GetCustomAttributes(inherit: false); + //ServiceKnownTypes = serviceType.GetCustomAttributes(inherit: false); + + ServiceKnownTypes = serviceType.Assembly.GetTypes() + .Where(t => t.Namespace == serviceType.Namespace) + .SelectMany(type => type.GetCustomAttributes(inherit: false)) + .GroupBy(t => t.TypeId) + .Select(t => t.First()) + .ToArray(); var types = Enumerable.Empty().Concat(ServiceType.GetInterfaces()); types = types.Concat(new[] { ServiceType });