Example #1
0
        public static IApplicationBuilder UseSoapEndpoint <T>(this IApplicationBuilder builder, Action <SoapCoreOptions> options)
        {
            var opt = new SoapCoreOptions();

            options(opt);

            // Generate encoders from Binding when they are not provided
            if (opt.MessageEncoders is null && opt.Binding != null)
            {
                var elements = opt.Binding.CreateBindingElements().FindAll <MessageEncodingBindingElement>();
                var encoders = new MessageEncoder[elements.Count];
                for (var i = 0; i < encoders.Length; i++)
                {
                    var factory = elements[i].CreateMessageEncoderFactory();
                    encoders[i] = factory.Encoder;
                }

                opt.MessageEncoders = encoders;
            }

            var soapOptions = new SoapOptions
            {
                ServiceType         = typeof(T),
                Path                = opt.Path,
                HttpsGetEnabled     = opt.HttpsGetEnabled,
                HttpGetEnabled      = opt.HttpGetEnabled,
                Binding             = opt.Binding,
                CaseInsensitivePath = opt.CaseInsensitivePath,
                MessageEncoders     = opt.MessageEncoders,
                SoapModelBounder    = opt.SoapModelBounder,
                SoapSerializer      = opt.SoapSerializer
            };

            return(builder.UseMiddleware <SoapEndpointMiddleware>(soapOptions));
        }
Example #2
0
        public static IEndpointConventionBuilder UseSoapEndpoint <T, T_MESSAGE>(this IEndpointRouteBuilder routes, Action <SoapCoreOptions> options)
            where T_MESSAGE : CustomMessage, new()
        {
            var opt = new SoapCoreOptions();

            options(opt);

            // Generate encoders from Binding when they are not provided
            if (opt.EncoderOptions is null && opt.Binding != null)
            {
                var elements       = opt.Binding.CreateBindingElements().FindAll <MessageEncodingBindingElement>();
                var encoderOptions = new SoapEncoderOptions[elements.Count];

                for (var i = 0; i < encoderOptions.Length; i++)
                {
                    var encoderOption = new SoapEncoderOptions
                    {
                        MessageVersion = elements[i].MessageVersion,
                        WriteEncoding  = Encoding.UTF8,
                        ReaderQuotas   = XmlDictionaryReaderQuotas.Max
                    };

                    if (elements[i] is TextMessageEncodingBindingElement textMessageEncodingBindingElement)
                    {
                        encoderOption.WriteEncoding = textMessageEncodingBindingElement.WriteEncoding;
                        encoderOption.ReaderQuotas  = textMessageEncodingBindingElement.ReaderQuotas;
                    }

                    encoderOptions[i] = encoderOption;
                }

                opt.EncoderOptions = encoderOptions;
            }

            var soapOptions = new SoapOptions
            {
                ServiceType         = typeof(T),
                Path                = opt.Path,
                HttpsGetEnabled     = opt.HttpsGetEnabled,
                HttpGetEnabled      = opt.HttpGetEnabled,
                Binding             = opt.Binding,
                CaseInsensitivePath = opt.CaseInsensitivePath,
                EncoderOptions      = opt.EncoderOptions,
                SoapModelBounder    = opt.SoapModelBounder,
                SoapSerializer      = opt.SoapSerializer,
                BufferLimit         = opt.BufferLimit,
                BufferThreshold     = opt.BufferThreshold,
                OmitXmlDeclaration  = opt.OmitXmlDeclaration,
                IndentXml           = opt.IndentXml
            };

            var pipeline = routes
                           .CreateApplicationBuilder()
                           .UseMiddleware <SoapEndpointMiddleware <T_MESSAGE> >(soapOptions)
                           .Build();

            return(routes.Map(soapOptions.Path, pipeline)
                   .WithDisplayName("SoapCore"));
        }
Example #3
0
        public static IApplicationBuilder UseSoapEndpoint <T>(this IApplicationBuilder builder, Action <SoapCoreOptions> options)
        {
            var opt = new SoapCoreOptions();

            options(opt);

            // Generate encoders from Binding when they are not provided
            if (opt.EncoderOptions is null && opt.Binding != null)
            {
                var elements       = opt.Binding.CreateBindingElements().FindAll <MessageEncodingBindingElement>();
                var encoderOptions = new SoapEncoderOptions[elements.Count];

                for (var i = 0; i < encoderOptions.Length; i++)
                {
                    var encoderOption = new SoapEncoderOptions
                    {
                        MessageVersion = elements[i].MessageVersion,
                        WriteEncoding  = Encoding.UTF8,
                        ReaderQuotas   = XmlDictionaryReaderQuotas.Max
                    };

                    if (elements[i] is TextMessageEncodingBindingElement textMessageEncodingBindingElement)
                    {
                        encoderOption.WriteEncoding = textMessageEncodingBindingElement.WriteEncoding;
                        encoderOption.ReaderQuotas  = textMessageEncodingBindingElement.ReaderQuotas;
                    }

                    encoderOptions[i] = encoderOption;
                }

                opt.EncoderOptions = encoderOptions;
            }

            var soapOptions = new SoapOptions
            {
                ServiceType         = typeof(T),
                Path                = opt.Path,
                HttpsGetEnabled     = opt.HttpsGetEnabled,
                HttpGetEnabled      = opt.HttpGetEnabled,
                Binding             = opt.Binding,
                CaseInsensitivePath = opt.CaseInsensitivePath,
                EncoderOptions      = opt.EncoderOptions,
                SoapModelBounder    = opt.SoapModelBounder,
                SoapSerializer      = opt.SoapSerializer,
                BufferThreshold     = opt.BufferThreshold,
                BufferLimit         = opt.BufferLimit
            };

            return(builder.UseMiddleware <SoapEndpointMiddleware>(soapOptions));
        }
Example #4
0
        public static IEndpointConventionBuilder UseSoapEndpoint <T, T_MESSAGE>(this IEndpointRouteBuilder routes, Action <SoapCoreOptions> options)
            where T_MESSAGE : CustomMessage, new()
        {
            var opt = new SoapCoreOptions();

            options(opt);

            // Generate encoders from Binding when they are not provided
            if (opt.EncoderOptions is null && opt.Binding != null)
            {
                var elements       = opt.Binding.CreateBindingElements().FindAll <MessageEncodingBindingElement>();
                var encoderOptions = new SoapEncoderOptions[elements.Count];

                for (var i = 0; i < encoderOptions.Length; i++)
                {
                    var encoderOption = new SoapEncoderOptions
                    {
                        MessageVersion = elements[i].MessageVersion,
                        WriteEncoding  = Encoding.UTF8,
                        ReaderQuotas   = XmlDictionaryReaderQuotas.Max
                    };

                    if (elements[i] is TextMessageEncodingBindingElement textMessageEncodingBindingElement)
                    {
                        encoderOption.WriteEncoding = textMessageEncodingBindingElement.WriteEncoding;
                        encoderOption.ReaderQuotas  = textMessageEncodingBindingElement.ReaderQuotas;
                    }

                    encoderOptions[i] = encoderOption;
                }

                opt.EncoderOptions = encoderOptions;
            }

            var soapOptions = SoapOptions.FromSoapCoreOptions <T>(opt);

            var pipeline = routes
                           .CreateApplicationBuilder()
                           .UseMiddleware <SoapEndpointMiddleware <T_MESSAGE> >(soapOptions)
                           .Build();

            return(routes.Map(soapOptions.Path, pipeline)
                   .WithDisplayName("SoapCore"));
        }
Example #5
0
        public static SoapOptions FromSoapCoreOptions <T>(SoapCoreOptions opt)
        {
            var soapOptions = new SoapOptions
            {
                ServiceType                 = typeof(T),
                Path                        = opt.Path,
                EncoderOptions              = opt.EncoderOptions,
                SoapSerializer              = opt.SoapSerializer,
                CaseInsensitivePath         = opt.CaseInsensitivePath,
                SoapModelBounder            = opt.SoapModelBounder,
                Binding                     = opt.Binding,
                BufferThreshold             = opt.BufferThreshold,
                BufferLimit                 = opt.BufferLimit,
                HttpsGetEnabled             = opt.HttpsGetEnabled,
                HttpGetEnabled              = opt.HttpGetEnabled,
                OmitXmlDeclaration          = opt.OmitXmlDeclaration,
                IndentXml                   = opt.IndentXml,
                XmlNamespacePrefixOverrides = opt.XmlNamespacePrefixOverrides
            };

            return(soapOptions);
        }
Example #6
0
 public static SoapOptions FromSoapCoreOptions <T>(SoapCoreOptions opt)
 {
     return(FromSoapCoreOptions(opt, typeof(T)));
 }