public WsdlTemplateBase GetWsdlTemplate(XsdMetadata operations, string baseUri, bool optimizeForFlash, string rawUrl)
		{
			var xsd = new XsdGenerator {
                OperationTypes = operations.GetAllTypes(),
				OptimizeForFlash = optimizeForFlash,
			}.ToString();

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

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

			return wsdlTemplate;
		}
        public WsdlTemplateBase GetWsdlTemplate(XsdMetadata operations, string baseUri, bool optimizeForFlash, string rawUrl, string serviceName)
		{
			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.ServiceName = serviceName;
            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 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 includeAllTypesInAssembly = httpReq.QueryString["includeAllTypes"] != null;
            var operations = new XsdMetadata(
                EndpointHost.Metadata, flash: optimizeForFlash, includeAllTypes: includeAllTypesInAssembly);

            try
            {
                var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, includeAllTypesInAssembly, 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"));
            }
        }
Пример #4
0
        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, false, "http://w3c.org/types");

            Assert.That(wsdlTemplate.ReplyOperationNames, Is.EquivalentTo(xsdMetadata.GetReplyOperationNames()));
            Assert.That(wsdlTemplate.OneWayOperationNames, Is.EquivalentTo(xsdMetadata.GetOneWayOperationNames()));
        }
		public override void Execute(HttpContext context)
		{
			EndpointHost.Config.AssertFeatures(Feature.Metadata);

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

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

			try
			{
				var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, context.Request.GetBaseUrl());
				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"));
			}
		}