Beispiel #1
0
        public override string ToString()
        {
            if (OperationTypes == null || OperationTypes.Count == 0)
            {
                return(null);
            }

            if (IncludeAllTypesInAssembly)
            {
                var uniqueTypes     = new List <Type>();
                var uniqueTypeNames = new List <string>();
                foreach (var type in OperationTypes)
                {
                    foreach (var assemblyType in type.Assembly.GetTypes())
                    {
                        if (assemblyType.GetCustomAttributes(typeof(DataContractAttribute), false).Length > 0)
                        {
                            var baseTypeWithSameName = ServiceOperations.GetBaseTypeWithTheSameName(assemblyType);
                            if (uniqueTypeNames.Contains(baseTypeWithSameName.Name))
                            {
                                log.WarnFormat("Skipping duplicate type with existing name '{0}'", baseTypeWithSameName.Name);
                            }
                            uniqueTypes.Add(baseTypeWithSameName);
                        }
                    }
                }
                this.OperationTypes = uniqueTypes;
            }

            var schemaSet   = XsdUtils.GetXmlSchemaSet(OperationTypes);
            var xsd         = XsdUtils.GetXsd(schemaSet);
            var filteredXsd = Filter(xsd);

            return(filteredXsd);
        }
Beispiel #2
0
        public new void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
        {
            var operations = EndpointHost.ServiceOperations;

            if (httpReq.QueryString["xsd"] != null)
            {
                var xsdNo     = Convert.ToInt32(httpReq.QueryString["xsd"]);
                var schemaSet = XsdUtils.GetXmlSchemaSet(operations.AllOperations.Types);
                var schemas   = schemaSet.Schemas();
                var i         = 0;
                if (xsdNo >= schemas.Count)
                {
                    throw new ArgumentOutOfRangeException("xsd");
                }
                httpRes.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++)
                    {
                        continue;
                    }
                    schema.Write(httpRes.OutputStream);
                    break;
                }
                return;
            }

            using (var sw = new StreamWriter(httpRes.OutputStream))
            {
                var writer = new HtmlTextWriter(sw);
                httpRes.ContentType = "text/html";
                ProcessOperations(writer, httpReq);
            }
        }
        public override void Execute(HttpContext context)
        {
            Request = context.Request;
            var operations = EndpointHost.ServiceOperations;

            if (context.Request.QueryString["xsd"] != null)
            {
                var xsdNo     = Convert.ToInt32(context.Request.QueryString["xsd"]);
                var schemaSet = XsdUtils.GetXmlSchemaSet(operations.AllOperations.Types);
                var schemas   = schemaSet.Schemas();
                var i         = 0;
                if (xsdNo >= schemas.Count)
                {
                    throw new ArgumentOutOfRangeException("xsd");
                }
                context.Response.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++)
                    {
                        continue;
                    }
                    schema.Write(context.Response.Output);
                    break;
                }
                return;
            }

            var writer = new HtmlTextWriter(context.Response.Output);

            context.Response.ContentType = "text/html";
            ProcessOperations(writer);
        }
Beispiel #4
0
        public void Can_load_ServiceModel_schemas()
        {
            var operations = CreateServiceOperations(typeof(GetCustomers).Assembly, typeof(GetCustomers).Namespace);
            var schemaSet  = XsdUtils.GetXmlSchemaSet(operations.AllOperations.Types);
            var schemas    = schemaSet.Schemas();

            Assert.IsNotNull(schemas);
        }
        public override Task ProcessRequestAsync(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
            {
                return(TypeConstants.EmptyTask);
            }

            if (!AssertAccess(httpReq, httpRes, httpReq.QueryString["op"]))
            {
                return(TypeConstants.EmptyTask);
            }


            if (httpReq.QueryString["xsd"] != null)
            {
#if !NETSTANDARD2_0
                var operationTypes = HostContext.Metadata.GetAllSoapOperationTypes();
                var xsdNo          = Convert.ToInt32(httpReq.QueryString["xsd"]);
                var schemaSet      = XsdUtils.GetXmlSchemaSet(operationTypes);
                var schemas        = schemaSet.Schemas();
                var i = 0;
                if (xsdNo >= schemas.Count)
                {
                    throw new ArgumentOutOfRangeException("xsd");
                }

                httpRes.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++)
                    {
                        continue;
                    }
                    schema.Write(httpRes.OutputStream);
                    break;
                }
#endif
            }
            else
            {
                using (var sw = new StreamWriter(httpRes.OutputStream))
                {
                    var writer = new HtmlTextWriter(sw);
                    httpRes.ContentType = "text/html; charset=utf-8";
                    ProcessOperations(writer, httpReq, httpRes);
                }
            }

            httpRes.EndHttpHandlerRequest(skipHeaders: true);

            return(TypeConstants.EmptyTask);
        }
        public override async Task ProcessRequestAsync(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
            {
                return;
            }

            if (!AssertAccess(httpReq, httpRes, httpReq.QueryString["op"]))
            {
                return;
            }


            if (httpReq.QueryString["xsd"] != null)
            {
#if !NETCORE
                var operationTypes = HostContext.Metadata.GetAllSoapOperationTypes();
                var xsdNo          = Convert.ToInt32(httpReq.QueryString["xsd"]);
                var schemaSet      = XsdUtils.GetXmlSchemaSet(operationTypes);
                var schemas        = schemaSet.Schemas();
                var i = 0;
                if (xsdNo >= schemas.Count)
                {
                    throw new ArgumentOutOfRangeException("xsd");
                }

                httpRes.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++)
                    {
                        continue;
                    }
                    schema.Write(httpRes.AllowSyncIO().OutputStream);
                    break;
                }
#endif
            }
            else
            {
                httpRes.ContentType = "text/html; charset=utf-8";
                await ProcessOperationsAsync(httpRes.OutputStream, httpReq, httpRes).ConfigAwait();
            }

            await httpRes.EndHttpHandlerRequestAsync(skipHeaders : true).ConfigAwait();
        }
        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
            {
                return;
            }

            if (!AssertAccess(httpReq, httpRes, httpReq.QueryString["op"]))
            {
                return;
            }

            var operationTypes = HostContext.Metadata.GetAllTypes();

            if (httpReq.QueryString["xsd"] != null)
            {
                var xsdNo     = Convert.ToInt32(httpReq.QueryString["xsd"]);
                var schemaSet = XsdUtils.GetXmlSchemaSet(operationTypes);
                var schemas   = schemaSet.Schemas();
                var i         = 0;
                if (xsdNo >= schemas.Count)
                {
                    throw new ArgumentOutOfRangeException("xsd");
                }
                httpRes.ContentType = "text/xml";
                foreach (XmlSchema schema in schemaSet.Schemas())
                {
                    if (xsdNo != i++)
                    {
                        continue;
                    }
                    schema.Write(httpRes.OutputStream);
                    break;
                }
                return;
            }

            using (var sw = new StreamWriter(httpRes.OutputStream))
            {
                var writer = new HtmlTextWriter(sw);
                httpRes.ContentType = "text/html";
                ProcessOperations(writer, httpReq, httpRes);
            }
        }
Beispiel #8
0
        public override string ToString()
        {
            if (OperationTypes == null || OperationTypes.Count == 0)
            {
                return(null);
            }

            var uniqueTypes     = new HashSet <Type>();
            var uniqueTypeNames = new List <string>();

            foreach (var opType in OperationTypes)
            {
                var refTypes = opType.GetReferencedTypes();
                foreach (var type in refTypes)
                {
                    if (type.IsDto())
                    {
                        var baseTypeWithSameName = XsdMetadata.GetBaseTypeWithTheSameName(type);
                        if (uniqueTypeNames.Contains(baseTypeWithSameName.GetOperationName()))
                        {
                            Logger.WarnFormat("Skipping duplicate type with existing name '{0}'", baseTypeWithSameName.GetOperationName());
                        }

                        if (!baseTypeWithSameName.IsGenericTypeDefinition && !baseTypeWithSameName.AllAttributes <ExcludeAttribute>().
                            Any(attr => attr.Feature.Has(Feature.Soap)))
                        {
                            uniqueTypes.Add(baseTypeWithSameName);
                        }
                    }
                }
            }

            this.OperationTypes = uniqueTypes;

            var schemaSet   = XsdUtils.GetXmlSchemaSet(OperationTypes);
            var xsd         = XsdUtils.GetXsd(schemaSet);
            var filteredXsd = Filter(xsd);

            return(filteredXsd);
        }
Beispiel #9
0
        public override string ToString()
        {
            if (OperationTypes == null || OperationTypes.Count == 0)
            {
                return(null);
            }

            var uniqueTypes     = new HashSet <Type>();
            var uniqueTypeNames = new List <string>();

            foreach (var opType in OperationTypes)
            {
                var refTypes = opType.GetReferencedTypes();
                foreach (var type in refTypes)
                {
                    if (type.IsDto())
                    {
                        var baseTypeWithSameName = XsdMetadata.GetBaseTypeWithTheSameName(type);
                        if (uniqueTypeNames.Contains(baseTypeWithSameName.GetOperationName()))
                        {
                            log.WarnFormat("Skipping duplicate type with existing name '{0}'", baseTypeWithSameName.GetOperationName());
                        }

                        if (HostContext.AppHost.ExportSoapType(baseTypeWithSameName))
                        {
                            uniqueTypes.Add(baseTypeWithSameName);
                        }
                    }
                }
            }

            this.OperationTypes = uniqueTypes;

            var schemaSet   = XsdUtils.GetXmlSchemaSet(OperationTypes);
            var xsd         = XsdUtils.GetXsd(schemaSet);
            var filteredXsd = Filter(xsd);

            return(filteredXsd);
        }
Beispiel #10
0
        public override string ToString()
        {
            if (OperationTypes == null || OperationTypes.Count == 0)
            {
                return(null);
            }

            var uniqueTypes     = new HashSet <Type>();
            var uniqueTypeNames = new List <string>();

            foreach (var type in OperationTypes)
            {
                foreach (var assemblyType in type.Assembly.GetTypes())
                {
                    if (assemblyType.GetCustomAttributes(typeof(DataContractAttribute), false).Length > 0)
                    {
                        var baseTypeWithSameName = XsdMetadata.GetBaseTypeWithTheSameName(assemblyType);
                        if (uniqueTypeNames.Contains(baseTypeWithSameName.GetOperationName()))
                        {
                            log.WarnFormat("Skipping duplicate type with existing name '{0}'", baseTypeWithSameName.GetOperationName());
                        }
                        uniqueTypes.Add(baseTypeWithSameName);
                    }
                }
            }

            uniqueTypes.RemoveWhere(x => x.IsGenericTypeDefinition());

            this.OperationTypes = uniqueTypes;

            var schemaSet   = XsdUtils.GetXmlSchemaSet(OperationTypes);
            var xsd         = XsdUtils.GetXsd(schemaSet);
            var filteredXsd = Filter(xsd);

            return(filteredXsd);
        }