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

            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 = XsdMetadata.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);
        }
        public WsdlTemplateBase GetWsdlTemplate(XsdMetadata operations, string baseUri, bool optimizeForFlash, string rawUrl)
        {
            var xsd = new XsdGenerator {
                OperationTypes   = operations.GetAllTypes(),
                OptimizeForFlash = optimizeForFlash,
            }.ToString();

            var soapFormat = GetType().Name.StartsWith("Soap11", StringComparison.OrdinalIgnoreCase)
                ? Format.Soap11 : Format.Soap12;

            var wsdlTemplate = GetWsdlTemplate();

            wsdlTemplate.Xsd = xsd;
            wsdlTemplate.ReplyOperationNames  = operations.GetReplyOperationNames(soapFormat);
            wsdlTemplate.OneWayOperationNames = operations.GetOneWayOperationNames(soapFormat);

            if (rawUrl.ToLower().StartsWith(baseUri))
            {
                wsdlTemplate.ReplyEndpointUri  = rawUrl;
                wsdlTemplate.OneWayEndpointUri = rawUrl;
            }
            else
            {
                var suffix = soapFormat == Format.Soap11 ? "soap11" : "soap12";
                wsdlTemplate.ReplyEndpointUri  = baseUri + suffix;
                wsdlTemplate.OneWayEndpointUri = baseUri + suffix;
            }

            return(wsdlTemplate);
        }
		public void Wsdl_state_is_correct()
		{
			var wsdlGenerator = new Soap11WsdlMetadataHandler();
		    var xsdMetadata = new XsdMetadata(Metadata);
		    var wsdlTemplate = wsdlGenerator.GetWsdlTemplate(xsdMetadata, "http://w3c.org/types", false, "http://w3c.org/types", "Service Name");

            Assert.That(wsdlTemplate.ReplyOperationNames, Is.EquivalentTo(xsdMetadata.GetReplyOperationNames(Format.Soap12)));
            Assert.That(wsdlTemplate.OneWayOperationNames, Is.EquivalentTo(xsdMetadata.GetOneWayOperationNames(Format.Soap12)));
		}
        public void Wsdl_state_is_correct()
        {
            var wsdlGenerator = new Soap11WsdlMetadataHandler();
            var xsdMetadata   = new XsdMetadata(Metadata);
            var wsdlTemplate  = wsdlGenerator.GetWsdlTemplate(xsdMetadata, "http://w3c.org/types", false, "http://w3c.org/types");

            Assert.That(wsdlTemplate.ReplyOperationNames, Is.EquivalentTo(xsdMetadata.GetReplyOperationNames(Format.Soap12)));
            Assert.That(wsdlTemplate.OneWayOperationNames, Is.EquivalentTo(xsdMetadata.GetOneWayOperationNames(Format.Soap12)));
        }
        public void Wsdl_state_is_correct()
        {
            using (var appHost = new BasicAppHost().Init())
            {
                var dummyServiceType = GetType();
                appHost.Metadata.Add(dummyServiceType, typeof(GetCustomer), typeof(GetCustomerResponse));
                appHost.Metadata.Add(dummyServiceType, typeof(GetCustomers), typeof(GetCustomersResponse));
                appHost.Metadata.Add(dummyServiceType, typeof(StoreCustomer), null);

                var wsdlGenerator = new Soap11WsdlMetadataHandler();
                var xsdMetadata   = new XsdMetadata(appHost.Metadata);
                var wsdlTemplate  = wsdlGenerator.GetWsdlTemplate(xsdMetadata, "http://w3c.org/types", false, "http://w3c.org/types", "Service Name");

                Assert.That(wsdlTemplate.ReplyOperationNames, Is.EquivalentTo(xsdMetadata.GetReplyOperationNames(Format.Soap12)));
                Assert.That(wsdlTemplate.OneWayOperationNames, Is.EquivalentTo(xsdMetadata.GetOneWayOperationNames(Format.Soap12)));
            }
        }
Example #6
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);
        }
Example #7
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);
        }
        public void Execute(IHttpRequest httpReq, IHttpResponse httpRes)
        {
            EndpointHost.Config.AssertFeatures(Feature.Metadata);

            httpRes.ContentType = "text/xml";

            var baseUri          = httpReq.GetParentBaseUrl();
            var optimizeForFlash = httpReq.QueryString["flash"] != null;
            var operations       = new XsdMetadata(EndpointHost.Metadata, flash: optimizeForFlash);

            try
            {
                var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, httpReq.GetBaseUrl());
                httpRes.Write(wsdlTemplate.ToString());
            }
            catch (Exception ex)
            {
                log.Error("Autogeneration of WSDL failed.", ex);

                httpRes.Write("Autogenerated WSDLs are not supported "
                              + (Env.IsMono ? "on Mono" : "with this configuration"));
            }
        }
        public override void Execute(HttpContextBase context)
        {
            HostContext.AppHost.AssertFeatures(Feature.Metadata);

            context.Response.ContentType = "text/xml";

            var baseUri          = context.Request.GetParentBaseUrl();
            var optimizeForFlash = context.Request.QueryString["flash"] != null;
            var operations       = new XsdMetadata(
                HostContext.Metadata, flash: optimizeForFlash);

            try
            {
                var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, context.Request.GetBaseUrl(), HostContext.Config.SoapServiceName);
                context.Response.Write(wsdlTemplate.ToString());
            }
            catch (Exception ex)
            {
                log.Error("Autogeneration of WSDL failed.", ex);

                context.Response.Write("Autogenerated WSDLs are not supported "
                                       + (Env.IsMono ? "on Mono" : "with this configuration"));
            }
        }
Example #10
0
        public Task Execute(IRequest httpReq, IResponse httpRes)
        {
            HostContext.AppHost.AssertFeatures(Feature.Metadata);

            httpRes.ContentType = "text/xml";

            var baseUri          = httpReq.GetParentBaseUrl();
            var optimizeForFlash = httpReq.QueryString["flash"] != null;
            var operations       = new XsdMetadata(HostContext.Metadata, flash: optimizeForFlash);

            try
            {
                var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, httpReq.GetBaseUrl(), HostContext.Config.SoapServiceName);
                var wsdl         = HostContext.AppHost.GenerateWsdl(wsdlTemplate);
                return(httpRes.WriteAsync(wsdl));
            }
            catch (Exception ex)
            {
                log.Error("Autogeneration of WSDL failed.", ex);

                return(httpRes.WriteAsync("Autogenerated WSDLs are not supported "
                                          + (Env.IsMono ? "on Mono" : "with this configuration")));
            }
        }