public SecurityHeader(System.ServiceModel.Channels.Message message, string actor, bool mustUnderstand, bool relay, SecurityStandardsManager standardsManager, SecurityAlgorithmSuite algorithmSuite, System.ServiceModel.Description.MessageDirection transferDirection) { if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message"); } if (actor == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("actor"); } if (standardsManager == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("standardsManager"); } if (algorithmSuite == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("algorithmSuite"); } this.message = message; this.actor = actor; this.mustUnderstand = mustUnderstand; this.relay = relay; this.standardsManager = standardsManager; this.algorithmSuite = algorithmSuite; this.transferDirection = transferDirection; }
/// <summary> /// Add token message at header to using NHibernate cache /// </summary> /// <param name="request"></param> /// <param name="channel"></param> /// <returns></returns> public object BeforeSendRequest(ref Message request, IClientChannel channel) { //get the extension item that the client may have put in the channel var item = channel.Extensions.Find<NHibernate2ndLevelCacheBehaviorExtensionItem>(); bool clientWantsToBypass = (item != null && item.BypassNHibernate2ndLevelCache); if (clientWantsToBypass || IsDefaultBypassNHibernateCache) { MessageHeader<bool> mhg = new MessageHeader<bool>(true); MessageHeader untyped = mhg.GetUntypedHeader("token", "ns"); request.Headers.Add(untyped); } return null; }
public override bool EndTryReceive(IAsyncResult result, out Message message) { throw new NotImplementedException(); }
protected abstract void AddProperties(Message message);
internal MessageTraceRecord(System.ServiceModel.Channels.Message message) { this.message = message; }
public void Foo (SMMessage msg, string s) { }
/// <summary> /// Processes a Trust 1.3 RSTR/Renew message synchronously. /// </summary> /// <param name="message">Incoming Request message.</param> /// <returns>Message with the serialized response.</returns> public Message ProcessTrust13RenewResponse(Message message) { return ProcessCore(message, _securityTokenServiceConfiguration.WSTrust13RequestSerializer, _securityTokenServiceConfiguration.WSTrust13ResponseSerializer, WSTrust13Constants.Actions.RenewResponse, WSTrust13Constants.Actions.RenewFinalResponse, WSTrust13Constants.NamespaceURI); }
/// <summary> /// Processes an Asynchronous call to Trust Feb 2005 Renew message. /// </summary> /// <param name="request">Incoming Request message.</param> /// <param name="callback">Callback to be invoked when the Asynchronous operation ends.</param> /// <param name="state">Asynchronous state.</param> /// <returns>IAsyncResult that should be passed back to the End method to complete the Asynchronous call.</returns> public IAsyncResult BeginTrustFeb2005Renew(Message request, AsyncCallback callback, object state) { return BeginProcessCore(request, _securityTokenServiceConfiguration.WSTrustFeb2005RequestSerializer, _securityTokenServiceConfiguration.WSTrustFeb2005ResponseSerializer, WSTrustFeb2005Constants.Actions.Renew, WSTrustFeb2005Constants.Actions.RenewResponse, WSTrustFeb2005Constants.NamespaceURI, callback, state); }
private static System.ServiceModel.Channels.Message EnsureWebMethod(this System.ServiceModel.Channels.Message request, string verb) { request.GetHttpRequestMessage().Method = verb; return(request); }
private static System.ServiceModel.Channels.Message EnsureWebBodyFormatting(this System.ServiceModel.Channels.Message request) { request.Properties.Add(WebBodyFormatMessageProperty.Name, new WebBodyFormatMessageProperty(WebContentFormat.Raw)); return(request); }
private static System.ServiceModel.Channels.Message EnsureWebAddressing(this System.ServiceModel.Channels.Message request, Uri url) { request.Headers.To = url; return(request); }
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel) { return(null); }
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { var cinfo = new ClientInfo(); //Collect any info that passed in the headers from Client, if any. cinfo.ServerTimeStamp = DateTime.Now; //Timestamp after the call is received. cinfo.Platform = "WCF"; OperationDescription operationDesc = GetOperationDescription(OperationContext.Current); if (operationDesc != null) { Type contractType = operationDesc.DeclaringContract.ContractType; cinfo.Action = operationDesc.Name; cinfo.TypeName = contractType.FullName; cinfo.AssemblyName = contractType.Assembly.GetName().Name; var syncMethod = operationDesc.SyncMethod; AuditDataChanges[] attr = null; // Eger OperationContract te verilen Method Name ile methodun orjinal adi farkli ise bu kontrol gerekiyor. yoksa methodu bulamiyor. var methods = contractType.GetMethods(); if (!operationDesc.Name.Equals(syncMethod.Name) || methods.Count() > 1) { var mi = methods.First(method => method.Name == syncMethod.Name && !method.IsGenericMethod && CommonHelper.ArraysEqual(method.GetParameters(), syncMethod.GetParameters())); if (mi != null) { attr = mi.GetCustomAttributes(typeof(AuditDataChanges), false) as AuditDataChanges[]; } } else { attr = contractType.GetMethod(operationDesc.Name).GetCustomAttributes(typeof(AuditDataChanges), false) as AuditDataChanges[]; } if (attr != null && attr.Length > 0) { cinfo.IsLogEnable = true; ServiceBase.AuditEnable = true; } } cinfo.ServerName = Dns.GetHostName(); cinfo.ServerProcessName = System.AppDomain.CurrentDomain.FriendlyName; if (OperationContext.Current != null) { var index = OperationContext.Current.IncomingMessageHeaders.FindHeader(ServiceBase.ClientComputerInfoKey, ServiceBase.ClientComputerInfoNamespaceKey); if (index > 0) { var clientComputerInfo = OperationContext.Current.IncomingMessageHeaders.GetHeader <ClientComputerInfo>(index); cinfo.ClientComputerInfo = clientComputerInfo; } } var messageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; if (messageProperty != null) { cinfo.ClientIp = messageProperty.Address; } ServiceBase.ClientInfo = cinfo; return(cinfo); }
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel) { Debug.WriteLine("====SimpleMessageInspector+BeforeSendRequest is called====="); Debug.WriteLine(request); return(null); }
public static MsmqIntegrationMessageProperty Get (SMessage message) { throw new NotImplementedException (); }
protected override Message DecodeMessage(byte[] buffer, ref int offset, ref int size, ref bool isAtEof, TimeSpan timeout) { while (!isAtEof && (size > 0)) { int envelopeSize; int count = this.decoder.Decode(buffer, offset, size); if (count > 0) { if (base.EnvelopeBuffer != null) { if (!object.ReferenceEquals(buffer, base.EnvelopeBuffer)) { Buffer.BlockCopy(buffer, offset, base.EnvelopeBuffer, base.EnvelopeOffset, count); } base.EnvelopeOffset += count; } offset += count; size -= count; } switch (this.decoder.CurrentState) { case ServerSessionDecoder.State.EnvelopeStart: envelopeSize = this.decoder.EnvelopeSize; if (envelopeSize > this.maxBufferSize) { base.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/MaxMessageSizeExceededFault", timeout); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(MaxMessageSizeStream.CreateMaxReceivedMessageSizeExceededException((long) this.maxBufferSize)); } break; case ServerSessionDecoder.State.ReadingEnvelopeBytes: case ServerSessionDecoder.State.ReadingEndRecord: { continue; } case ServerSessionDecoder.State.EnvelopeEnd: { if (base.EnvelopeBuffer == null) { continue; } using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity(true) : null) { if (DiagnosticUtility.ShouldUseActivity) { ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("ActivityProcessingMessage", new object[] { TraceUtility.RetrieveMessageNumber() }), ActivityType.ProcessMessage); } Message message = null; try { message = this.messageEncoder.ReadMessage(new ArraySegment<byte>(base.EnvelopeBuffer, 0, base.EnvelopeSize), this.bufferManager, this.contentType); } catch (XmlException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("MessageXmlProtocolError"), exception)); } if (DiagnosticUtility.ShouldUseActivity) { TraceUtility.TransferFromTransport(message); } base.EnvelopeBuffer = null; return message; } } case ServerSessionDecoder.State.End: goto Label_01A8; default: { continue; } } base.EnvelopeBuffer = this.bufferManager.TakeBuffer(envelopeSize); base.EnvelopeOffset = 0; base.EnvelopeSize = envelopeSize; continue; Label_01A8: isAtEof = true; } return null; }
object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { return(null); }
void IDispatchMessageInspector.BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { return; }
public IAsyncResult BeginRequest(System.ServiceModel.Channels.Message message, TimeSpan timeout, AsyncCallback callback, object state) { throw new NotImplementedException(); }
/// <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; }
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel) { HttpRequestMessageProperty httpRequestMessageProperty; object httpRequestMessageObject = null; if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out httpRequestMessageObject)) { httpRequestMessageProperty = httpRequestMessageObject as HttpRequestMessageProperty; if (string.IsNullOrEmpty(httpRequestMessageProperty.Headers[HTTP_AUTHORIZATION_HEADER])) { httpRequestMessageProperty.Headers[HTTP_AUTHORIZATION_HEADER] = GetAuthorizationInfo(); } } else { httpRequestMessageProperty = new HttpRequestMessageProperty(); httpRequestMessageProperty.Headers.Add(HTTP_AUTHORIZATION_HEADER, GetAuthorizationInfo()); request.Properties.Add(HttpRequestMessageProperty.Name, httpRequestMessageProperty); } httpRequestMessageProperty.Headers.Add("x-ms-version", this.Client.ApiVersion); if (Client.RequestId != Guid.Empty) { httpRequestMessageProperty.Headers.Add("x-ms-request-id", Client.RequestId.ToString()); } if (Client.Tracing) { httpRequestMessageProperty.Headers.Add("x-ms-tracing", true.ToString()); } if (!String.IsNullOrEmpty(Client.StampName)) { httpRequestMessageProperty.Headers.Add("x-ms-stamp", Client.StampName); } if (!String.IsNullOrEmpty(Client.UserAgent)) { httpRequestMessageProperty.Headers.Add("User-Agent", Client.UserAgent); } if (!string.IsNullOrEmpty(Client.AcceptLanguage)) { httpRequestMessageProperty.Headers.Add(HTTP_ACCEPT_LANGUAGE_HEADER, Client.AcceptLanguage); } // Add extra headers foreach (var item in Client.ExtraHeaders) { httpRequestMessageProperty.Headers.Add(item.Key, item.Value); } if (Client.TraceRequestReply) { Console.WriteLine("### REQUEST"); request = TraceOutMessage(request, httpRequestMessageProperty); } return(null); }
/// <summary> /// Processes an Asynchronous call to Trust 1.3 Validate message. /// </summary> /// <param name="request">Incoming Request message.</param> /// <param name="callback">Callback to be invoked when the Asynchronous operation ends.</param> /// <param name="state">Asynchronous state.</param> /// <returns>IAsyncResult that should be passed back to the End method to complete the Asynchronous call.</returns> public IAsyncResult BeginTrust13Validate(Message request, AsyncCallback callback, object state) { return BeginProcessCore(request, _securityTokenServiceConfiguration.WSTrust13RequestSerializer, _securityTokenServiceConfiguration.WSTrust13ResponseSerializer, WSTrust13Constants.Actions.Validate, WSTrust13Constants.Actions.ValidateFinalResponse, WSTrust13Constants.NamespaceURI, callback, state); }
void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref System.ServiceModel.Channels.Message fault) { m_ErrorHandler.ProvideFault(error, version, ref fault); }
/// <summary> /// Enables the creation of a custom System.ServiceModel.FaultException{TDetail} /// that is returned from an exception in the course of a service method. /// </summary> /// <param name="error">The System.Exception object thrown in the course of the service operation.</param> /// <param name="version">The SOAP version of the message.</param> /// <param name="fault">The System.ServiceModel.Channels.Message object that is returned to the client, or service in duplex case</param> public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault) { if (error is FaultException <ServiceError> ) { MessageFault messageFault = ((FaultException <ServiceError>)error).CreateMessageFault(); //propagate FaultException fault = Message.CreateMessage(version, messageFault, ((FaultException <ServiceError>)error).Action); } else { //create service error ServiceError defaultError = new ServiceError() { ErrorMessage = Resources.Messages.message_DefaultErrorMessage }; //Create fault exception and message fault FaultException <ServiceError> defaultFaultException = new FaultException <ServiceError>(defaultError); MessageFault defaultMessageFault = defaultFaultException.CreateMessageFault(); //propagate FaultException fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action); } }
public SMMessage GetMessage1(SMMessage req) { return(null); }
private Exception ProcessHttpAddressing(Message message) { Exception exception = null; this.AddProperties(message); if (message.Version.Addressing == AddressingVersion.None) { bool flag = false; try { flag = message.Headers.Action == null; } catch (XmlException exception2) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information); } } catch (CommunicationException exception3) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Information); } } if (!flag) { exception = new ProtocolException(System.ServiceModel.SR.GetString("HttpAddressingNoneHeaderOnWire", new object[] { XD.AddressingDictionary.Action.Value })); } bool flag2 = false; try { flag2 = message.Headers.To == null; } catch (XmlException exception4) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception4, TraceEventType.Information); } } catch (CommunicationException exception5) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception5, TraceEventType.Information); } } if (!flag2) { exception = new ProtocolException(System.ServiceModel.SR.GetString("HttpAddressingNoneHeaderOnWire", new object[] { XD.AddressingDictionary.To.Value })); } message.Headers.To = message.Properties.Via; } if (this.isRequest) { string soapActionHeader = null; if (message.Version.Envelope == EnvelopeVersion.Soap11) { soapActionHeader = this.SoapActionHeader; } else if ((message.Version.Envelope == EnvelopeVersion.Soap12) && !string.IsNullOrEmpty(this.ContentType)) { System.Net.Mime.ContentType type = new System.Net.Mime.ContentType(this.ContentType); if ((type.MediaType == "multipart/related") && type.Parameters.ContainsKey("start-info")) { soapActionHeader = new System.Net.Mime.ContentType(type.Parameters["start-info"]).Parameters["action"]; } if (soapActionHeader == null) { soapActionHeader = type.Parameters["action"]; } } if (soapActionHeader != null) { soapActionHeader = UrlUtility.UrlDecode(soapActionHeader, Encoding.UTF8); if (((soapActionHeader.Length >= 2) && (soapActionHeader[0] == '"')) && (soapActionHeader[soapActionHeader.Length - 1] == '"')) { soapActionHeader = soapActionHeader.Substring(1, soapActionHeader.Length - 2); } if (message.Version.Addressing == AddressingVersion.None) { message.Headers.Action = soapActionHeader; } try { if ((soapActionHeader.Length > 0) && (string.Compare(message.Headers.Action, soapActionHeader, StringComparison.Ordinal) != 0)) { exception = new ActionMismatchAddressingException(System.ServiceModel.SR.GetString("HttpSoapActionMismatchFault", new object[] { message.Headers.Action, soapActionHeader }), message.Headers.Action, soapActionHeader); } } catch (XmlException exception6) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception6, TraceEventType.Information); } } catch (CommunicationException exception7) { if (DiagnosticUtility.ShouldTraceInformation) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception7, TraceEventType.Information); } } } } this.ApplyChannelBinding(message); if (DiagnosticUtility.ShouldUseActivity) { TraceUtility.TransferFromTransport(message); } if (DiagnosticUtility.ShouldTraceInformation) { TraceUtility.TraceEvent(TraceEventType.Information, 0x40013, System.ServiceModel.SR.GetString("TraceCodeMessageReceived"), MessageTransmitTraceRecord.CreateReceiveTraceRecord(message), this, null, message); } if (MessageLogger.LoggingEnabled && (message.Version.Addressing == AddressingVersion.None)) { MessageLogger.LogMessage(ref message, MessageLoggingSource.LastChance | MessageLoggingSource.TransportReceive); } return(exception); }
private static void LogMessage(string fileName, ref System.ServiceModel.Channels.Message request) { //Logger.logDirectory = WMCommon.Properties.Settings.Default.MultispeakLogDirectory_DEV; //Logger.logFileName = fileName; //Logger.LogMessage(ref request); }
public SMMessage Get (SMMessage req) { return null; }
public object GetInstance(InstanceContext instanceContext, Message message) { return new ChatService(_userRepository, _messageRepository); }
public override bool TryReceive(TimeSpan timeout, out Message message) { throw new NotImplementedException(); }
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { _response = reply.Properties[HttpResponseMessageProperty.Name.ToString()] as HttpResponseMessageProperty; }
protected override void PrepareMessage(Message message) { this.channelListener.RaiseMessageReceived(); base.PrepareMessage(message); }
/// <summary> /// If you want to communicate the exception details to the service client /// as proper fault message /// here is the place to do it /// If we want to suppress the communication about the exception, /// set fault to null /// </summary> /// <param name="error"></param> /// <param name="version"></param> /// <param name="fault"></param> public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault) { var loggerGlobal = NLog.LogManager.GetCurrentClassLogger(); NLog.LogManager.Configuration.Variables["requesturl"] = System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri.OriginalString; NLog.LogManager.Configuration.Variables["template"] = System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.UriTemplateMatch.Template.ToString(); NLog.LogManager.Configuration.Variables["targetsite"] = error.TargetSite.ToString(); loggerGlobal.Error(error, string.Empty); var newEx = new FaultException(string.Format("Exception caught at Service Application GlobalErrorHandler{0}Method: {1}{2}Message: {3}{4}InnerException: {5}", Environment.NewLine, error.TargetSite.Name, Environment.NewLine, error.Message, Environment.NewLine, error.InnerException == null ? string.Empty : error.InnerException.Message)); MessageFault msgFault = newEx.CreateMessageFault(); fault = Message.CreateMessage(version, msgFault, newEx.Action); }
internal AsyncMetadataReferenceRetriever(IMetadataExchange metadataClient, MessageVersion messageVersion, TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state) { this.message = MetadataExchangeClient.MetadataReferenceRetriever.CreateGetMessage(messageVersion); ((IClientChannel) metadataClient).OperationTimeout = timeoutHelper.RemainingTime(); IAsyncResult result = metadataClient.BeginGet(this.message, Fx.ThunkCallback(new AsyncCallback(this.RequestCallback)), metadataClient); if (result.CompletedSynchronously) { this.HandleResult(result); base.Complete(true); } }
/// <summary> /// Enables the creation of a custom <see cref="T:System.ServiceModel.FaultException`1" /> that is returned from an exception in the course of a service method. /// </summary> /// <param name="error">The <see cref="T:System.Exception" /> object thrown in the course of the service operation.</param> /// <param name="version">The SOAP version of the message.</param> /// <param name="fault">The <see cref="T:System.ServiceModel.Channels.Message" /> object that is returned to the client, or service, in the duplex case.</param> public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault) { fault = GetJsonFaultMessage(version, error); this.ApplyJsonSettings(ref fault); this.ApplyHttpResponseSettings(ref fault, System.Net.HttpStatusCode.BadRequest, "Error"); }
public void AfterReceiveReply(ref Message reply, object correlationState) { }
public SMMessage Get(SMMessage msg) { return(Channel.Get(msg)); }
internal void Init(System.ServiceModel.Channels.Message msg, int countMax, XmlSpace space, bool includeBody, bool atomize) { this.counter = this; this.nodeCount = countMax; this.nodeCountMax = countMax; this.dom = this; this.location = 1; this.specialParent = 0; this.includeBody = includeBody; this.message = msg; this.headers = msg.Headers; this.space = space; this.atomize = false; int num = (msg.Headers.Count + 6) + 1; if ((this.nodes == null) || (this.nodes.Length < num)) { this.nodes = new Node[num + 50]; } else { Array.Clear(this.nodes, 1, this.nextFreeIndex - 1); } this.bodyIndex = num - 1; this.nextFreeIndex = num; Array.Copy(BlankDom, this.nodes, 6); string str = msg.Version.Envelope.Namespace; this.nodes[2].ns = str; this.nodes[3].val = str; this.nodes[5].ns = str; this.nodes[5].nextSibling = this.bodyIndex; this.nodes[5].firstChild = (this.bodyIndex != 6) ? 6 : 0; if (msg.Headers.Count > 0) { int index = 6; for (int i = 0; i < msg.Headers.Count; i++) { this.nodes[index].type = XPathNodeType.Element; this.nodes[index].parent = 5; this.nodes[index].nextSibling = index + 1; this.nodes[index].prevSibling = index - 1; MessageHeaderInfo info = msg.Headers[i]; this.nodes[index].ns = info.Namespace; this.nodes[index].name = info.Name; this.nodes[index].firstChild = -1; index++; } this.nodes[6].prevSibling = 0; this.nodes[this.bodyIndex - 1].nextSibling = 0; } this.nodes[this.bodyIndex].type = XPathNodeType.Element; this.nodes[this.bodyIndex].prefix = "s"; this.nodes[this.bodyIndex].ns = str; this.nodes[this.bodyIndex].name = "Body"; this.nodes[this.bodyIndex].parent = 2; this.nodes[this.bodyIndex].prevSibling = 5; this.nodes[this.bodyIndex].firstNamespace = 3; this.nodes[this.bodyIndex].firstChild = -1; if (atomize) { this.Atomize(); } }
public IAsyncResult BeginGet(SMMessage request, AsyncCallback callback, object state) { throw new NotImplementedException(); }
/// <summary> /// Handles Synchronous calls to the STS. /// </summary> /// <param name="requestMessage">Incoming Request message.</param> /// <param name="requestSerializer">Trust Request Serializer.</param> /// <param name="responseSerializer">Trust Response Serializer.</param> /// <param name="requestAction">Request SOAP action.</param> /// <param name="responseAction">Response SOAP action.</param> /// <param name="trustNamespace">Namespace URI of the trust version of the incoming request.</param> /// <returns>Response message that contains the serialized RSTR.</returns> /// <exception cref="ArgumentNullException">One of the argument is null.</exception> protected virtual Message ProcessCore(Message requestMessage, WSTrustRequestSerializer requestSerializer, WSTrustResponseSerializer responseSerializer, string requestAction, string responseAction, string trustNamespace) { if (requestMessage == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestMessage"); } if (requestSerializer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestSerializer"); } if (responseSerializer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("responseSerializer"); } if (String.IsNullOrEmpty(requestAction)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestAction"); } if (String.IsNullOrEmpty(responseAction)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("responseAction"); } if (String.IsNullOrEmpty(trustNamespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustNamespace"); } Message response = null; try { Fx.Assert(OperationContext.Current != null, ""); Fx.Assert(OperationContext.Current.RequestContext != null, ""); // // Create the Serialization and Dispatch context objects. // WSTrustSerializationContext serializationContext = CreateSerializationContext(); DispatchContext dispatchContext = CreateDispatchContext(requestMessage, requestAction, responseAction, trustNamespace, requestSerializer, responseSerializer, serializationContext); // // Validate the dispatch context. // ValidateDispatchContext(dispatchContext); // // Dispatch the STS message. // DispatchRequest(dispatchContext); // // Create the response Message object with the appropriate action. // response = Message.CreateMessage(OperationContext.Current.RequestContext.RequestMessage.Version, dispatchContext.ResponseAction, new WSTrustResponseBodyWriter(dispatchContext.ResponseMessage, responseSerializer, serializationContext)); } catch (Exception ex) { if (!HandleException(ex, trustNamespace, requestAction, requestMessage.Version.Envelope)) { throw; } } return response; }
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { }
/// <summary> /// Handles Asynchronous call to the STS. /// </summary> /// <param name="requestMessage">Incoming Request message.</param> /// <param name="requestSerializer">Trust Request Serializer.</param> /// <param name="responseSerializer">Trust Response Serializer.</param> /// <param name="requestAction">Request SOAP action.</param> /// <param name="responseAction">Response SOAP action.</param> /// <param name="trustNamespace">Namespace URI of the trust version of the incoming request.</param> /// <param name="callback">Callback that gets invoked when the Asynchronous call ends.</param> /// <param name="state">state information of the Asynchronous call.</param> /// <returns>IAsyncResult that should be passed back to the End method to complete the Asynchronous call.</returns> /// <exception cref="ArgumentNullException">One of the argument is null.</exception> protected virtual IAsyncResult BeginProcessCore(Message requestMessage, WSTrustRequestSerializer requestSerializer, WSTrustResponseSerializer responseSerializer, string requestAction, string responseAction, string trustNamespace, AsyncCallback callback, object state) { if (requestMessage == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("request"); } if (requestSerializer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestSerializer"); } if (responseSerializer == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("responseSerializer"); } if (String.IsNullOrEmpty(requestAction)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestAction"); } if (String.IsNullOrEmpty(responseAction)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("responseAction"); } if (String.IsNullOrEmpty(trustNamespace)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustNamespace"); } IAsyncResult result = null; try { Fx.Assert(OperationContext.Current != null, ""); Fx.Assert(OperationContext.Current.RequestContext != null, ""); // // Create the Serialization and Dispatch context objects. // WSTrustSerializationContext serializationContext = CreateSerializationContext(); DispatchContext dispatchContext = CreateDispatchContext(requestMessage, requestAction, responseAction, trustNamespace, requestSerializer, responseSerializer, serializationContext); // // Validate the dispatch context. // ValidateDispatchContext(dispatchContext); // // Dispatch the message asynchronously. // result = new ProcessCoreAsyncResult(this, dispatchContext, OperationContext.Current.RequestContext.RequestMessage.Version, responseSerializer, serializationContext, callback, state); } catch (Exception ex) { if (!HandleException(ex, trustNamespace, requestAction, requestMessage.Version.Envelope)) { throw; } } return result; }
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply, object correlationState) { }
/// <summary> /// Processes a Trust Feb 2005 RSTR/Validate message synchronously. /// </summary> /// <param name="message">Incoming Request message.</param> /// <returns>Message with the serialized response.</returns> public Message ProcessTrustFeb2005ValidateResponse(Message message) { return ProcessCore(message, _securityTokenServiceConfiguration.WSTrustFeb2005RequestSerializer, _securityTokenServiceConfiguration.WSTrustFeb2005ResponseSerializer, WSTrustFeb2005Constants.Actions.ValidateResponse, WSTrustFeb2005Constants.Actions.ValidateResponse, WSTrustFeb2005Constants.NamespaceURI); }
public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) { return null; }
public string GetMessageEnvelope(Message msg) { var sb = new StringBuilder(); using (var sw = XmlWriter.Create(new StringWriter(sb))) { msg.WriteMessage(sw); sw.Flush(); return sb.ToString(); } }
IAsyncResult IOutputChannel.BeginSend(System.ServiceModel.Channels.Message message, TimeSpan timeout, AsyncCallback callback, object state) { return(this.channel.BeginSend(message, timeout, callback, state)); }
internal UnknownMessageReceivedEventArgs(System.ServiceModel.Channels.Message message) { this.message = message; }
/// <summary> /// ProvideFault /// </summary> /// <param name="exception"></param> /// <param name="version"></param> /// <param name="fault"></param> public void ProvideFault(Exception exception, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault) { //Propogate the exception back to the client. //if (exception is FaultException) // return; //else //{ // FaultException faultException = new FaultException(exception.Message); // MessageFault messageFault = faultException.CreateMessageFault(); // fault = Message.CreateMessage(version, messageFault, faultException.Action); //} }