本文整理汇总了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);
}
}
示例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);
}
}