当前位置: 首页>>代码示例>>C#>>正文


C# EndpointAttributes.ToSoapFeature方法代码示例

本文整理汇总了C#中EndpointAttributes.ToSoapFeature方法的典型用法代码示例。如果您正苦于以下问题:C# EndpointAttributes.ToSoapFeature方法的具体用法?C# EndpointAttributes.ToSoapFeature怎么用?C# EndpointAttributes.ToSoapFeature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EndpointAttributes的用法示例。


在下文中一共展示了EndpointAttributes.ToSoapFeature方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteMessage

        protected Message ExecuteMessage(Message message, EndpointAttributes endpointAttributes, IHttpRequest httpRequest, IHttpResponse httpResponse)
        {
            var soapFeature = endpointAttributes.ToSoapFeature();
            EndpointHost.Config.AssertFeatures(soapFeature);

            var httpReq = HttpContext.Current != null && httpRequest == null
                    ? new HttpRequestWrapper(HttpContext.Current.Request)
                    : httpRequest;
            var httpRes = HttpContext.Current != null && httpResponse == null
                ? new HttpResponseWrapper(HttpContext.Current.Response)
                : httpResponse;

            if (httpReq == null)
                throw new ArgumentNullException("httpRequest");

            if (httpRes == null)
                throw new ArgumentNullException("httpResponse");

            if (EndpointHost.ApplyPreRequestFilters(httpReq, httpRes))
                return PrepareEmptyResponse(message, httpReq);

            var requestMsg = message ?? GetRequestMessageFromStream(httpReq.InputStream);
            string requestXml = GetRequestXml(requestMsg);
            var requestType = GetRequestType(requestMsg, requestXml);
            if (!EndpointHost.Metadata.CanAccess(endpointAttributes, soapFeature.ToFormat(), requestType.Name))
                throw EndpointHost.Config.UnauthorizedAccess(endpointAttributes);

            try
            {
                var request = DataContractDeserializer.Instance.Parse(requestXml, requestType);
                var requiresSoapMessage = request as IRequiresSoapMessage;
                if (requiresSoapMessage != null)
                {
                    requiresSoapMessage.Message = requestMsg;
                }

                httpReq.OperationName = requestType.Name;
                httpReq.SetItem("SoapMessage", requestMsg);

                var hasRequestFilters = EndpointHost.RequestFilters.Count > 0
                    || FilterAttributeCache.GetRequestFilterAttributes(request.GetType()).Any();

                if (hasRequestFilters && EndpointHost.ApplyRequestFilters(httpReq, httpRes, request))
                    return EmptyResponse(requestMsg, requestType);

                var response = ExecuteService(request, endpointAttributes, httpReq, httpRes);

                var hasResponseFilters = EndpointHost.ResponseFilters.Count > 0
                   || FilterAttributeCache.GetResponseFilterAttributes(response.GetType()).Any();

                if (hasResponseFilters && EndpointHost.ApplyResponseFilters(httpReq, httpRes, response))
                    return EmptyResponse(requestMsg, requestType);

                var httpResult = response as IHttpResult;
                if (httpResult != null)
                    response = httpResult.Response;

                return requestMsg.Headers.Action == null
                    ? Message.CreateMessage(requestMsg.Version, null, response)
                    : Message.CreateMessage(requestMsg.Version, requestType.Name + "Response", response);
            }
            catch (Exception ex)
            {
                throw new SerializationException("3) Error trying to deserialize requestType: "
                    + requestType
                    + ", xml body: " + requestXml, ex);
            }
        }
开发者ID:JonCanning,项目名称:ServiceStack,代码行数:68,代码来源:SoapHandler.cs

示例2: ExecuteMessage

        protected Message ExecuteMessage(Message requestMsg, EndpointAttributes endpointAttributes, IHttpRequest httpRequest, IHttpResponse httpResponse)
        {
            var soapFeatue = endpointAttributes.ToSoapFeature();
            EndpointHost.Config.AssertFeatures(soapFeatue);

            string requestXml;
            using (var reader = requestMsg.GetReaderAtBodyContents())
            {
                requestXml = reader.ReadOuterXml();
            }

            var requestType = GetRequestType(requestMsg, requestXml);
            if (!EndpointHost.Metadata.CanAccess(endpointAttributes, soapFeatue.ToFormat(), requestType.Name))
                throw EndpointHost.Config.UnauthorizedAccess(endpointAttributes);

            try
            {
                var request = DataContractDeserializer.Instance.Parse(requestXml, requestType);
                var requiresSoapMessage = request as IRequiresSoapMessage;
                if (requiresSoapMessage != null)
                {
                    requiresSoapMessage.Message = requestMsg;
                }

                var httpReq = HttpContext.Current != null
                    ? new HttpRequestWrapper(requestType.Name, HttpContext.Current.Request)
                    : httpRequest;
                var httpRes = HttpContext.Current != null
                    ? new HttpResponseWrapper(HttpContext.Current.Response)
                    : httpResponse;

                if (EndpointHost.ApplyPreRequestFilters(httpReq, httpRes))
                    return EmptyResponse(requestMsg, requestType);

                var hasRequestFilters = EndpointHost.RequestFilters.Count > 0
                    || FilterAttributeCache.GetRequestFilterAttributes(request.GetType()).Any();

                if (hasRequestFilters && EndpointHost.ApplyRequestFilters(httpReq, httpRes, request))
                    return EmptyResponse(requestMsg, requestType);

                var response = ExecuteService(request, endpointAttributes, httpReq, httpRes);

                var hasResponseFilters = EndpointHost.ResponseFilters.Count > 0
                   || FilterAttributeCache.GetResponseFilterAttributes(response.GetType()).Any();

                if (hasResponseFilters && EndpointHost.ApplyResponseFilters(httpReq, httpRes, response))
                    return EmptyResponse(requestMsg, requestType);

                var httpResult = response as IHttpResult;
                if (httpResult != null)
                    response = httpResult.Response;

                return requestMsg.Headers.Action == null
                    ? Message.CreateMessage(requestMsg.Version, null, response)
                    : Message.CreateMessage(requestMsg.Version, requestType.Name + "Response", response);
            }
            catch (Exception ex)
            {
                throw new SerializationException("3) Error trying to deserialize requestType: "
                    + requestType
                    + ", xml body: " + requestXml, ex);
            }
        }
开发者ID:bradgearon,项目名称:ServiceStack,代码行数:63,代码来源:SoapHandler.cs


注:本文中的EndpointAttributes.ToSoapFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。