本文整理汇总了C#中System.ServiceModel.Channels.Message.GetReaderAtBodyContents方法的典型用法代码示例。如果您正苦于以下问题:C# Message.GetReaderAtBodyContents方法的具体用法?C# Message.GetReaderAtBodyContents怎么用?C# Message.GetReaderAtBodyContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Channels.Message
的用法示例。
在下文中一共展示了Message.GetReaderAtBodyContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDispatchContext
/// <summary>
/// Creates a <see cref="DispatchContext"/> object for use by the <see cref="DispatchRequest"/> method.
/// </summary>
/// <param name="requestMessage">The incoming request message.</param>
/// <param name="requestAction">The SOAP action of the request.</param>
/// <param name="responseAction">The default SOAP action of the response.</param>
/// <param name="trustNamespace">Namespace URI of the trust version of the incoming request.</param>
/// <param name="requestSerializer">The <see cref="WSTrustRequestSerializer"/> used to deserialize
/// incoming RST messages.</param>
/// <param name="responseSerializer">The <see cref="WSTrustResponseSerializer"/> used to deserialize
/// incoming RSTR messages.</param>
/// <param name="serializationContext">The <see cref="WSTrustSerializationContext"/> to use
/// when deserializing incoming messages.</param>
/// <returns>A <see cref="DispatchContext"/> object.</returns>
protected virtual DispatchContext CreateDispatchContext(Message requestMessage,
string requestAction,
string responseAction,
string trustNamespace,
WSTrustRequestSerializer requestSerializer,
WSTrustResponseSerializer responseSerializer,
WSTrustSerializationContext serializationContext)
{
DispatchContext dispatchContext = new DispatchContext()
{
Principal = OperationContext.Current.ClaimsPrincipal as ClaimsPrincipal,
RequestAction = requestAction,
ResponseAction = responseAction,
TrustNamespace = trustNamespace
};
XmlReader requestBodyReader = requestMessage.GetReaderAtBodyContents();
//
// Take a peek at the request with the serializers to figure out if this is a standard incoming
// RST or if this is an instance of a challenge-response style message pattern where an RSTR comes in.
//
if (requestSerializer.CanRead(requestBodyReader))
{
dispatchContext.RequestMessage = requestSerializer.ReadXml(requestBodyReader, serializationContext);
}
else if (responseSerializer.CanRead(requestBodyReader))
{
dispatchContext.RequestMessage = responseSerializer.ReadXml(requestBodyReader, serializationContext);
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidRequestException(SR.GetString(SR.ID3114)));
}
//
// CAUTION: Don't create the STS until after the RST or RSTR is deserialized or the test team
// has major infrastructure problems.
//
dispatchContext.SecurityTokenService = CreateSTS();
return dispatchContext;
}