示例#1
0
        private Message ProcessMeta(HttpContext httpContext)
        {
            var baseUrl = httpContext.Request.Scheme + "://" + httpContext.Request.Host + httpContext.Request.PathBase + httpContext.Request.Path;

            var bodyWriter = new MetaBodyWriter(_service, baseUrl);

            var responseMessage = Message.CreateMessage(_messageEncoder.MessageVersion, null, bodyWriter);

            responseMessage = new MetaMessage(responseMessage, _service);

            httpContext.Response.ContentType = _messageEncoder.ContentType;
            _messageEncoder.WriteMessage(responseMessage, httpContext.Response.Body);

            return(responseMessage);
        }
示例#2
0
        private async Task <string> GetWsdlFromMetaBodyWriter <T>()
        {
            var service         = new ServiceDescription(typeof(T));
            var baseUrl         = "http://tempuri.org/";
            var bodyWriter      = new MetaBodyWriter(service, baseUrl, null);
            var encoder         = new SoapMessageEncoder(MessageVersion.Soap12WSAddressingAugust2004, System.Text.Encoding.UTF8, XmlDictionaryReaderQuotas.Max, false, true);
            var responseMessage = Message.CreateMessage(encoder.MessageVersion, null, bodyWriter);

            responseMessage = new MetaMessage(responseMessage, service, null);

            var memoryStream = new MemoryStream();
            await encoder.WriteMessageAsync(responseMessage, memoryStream);

            memoryStream.Position = 0;

            var streamReader = new StreamReader(memoryStream);
            var result       = streamReader.ReadToEnd();

            return(result);
        }