/// <summary> /// process a giop locate request message. /// </summary> private ServerProcessing ProcessLocateRequestMessage(IServerChannelSinkStack sinkStack, ITransportHeaders requestHeaders, CdrMessageInputStream msgInput, GiopServerConnection serverCon, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { responseHeaders = null; LocateRequestMessage deserReqMsg = m_messageHandler.ParseIncomingLocateRequestMessage(msgInput); // TODO: dummy implementation, don't check yet LocateReplyMessage response = new LocateReplyMessage(LocateStatus.OBJECT_HERE); responseMsg = response; PrepareResponseHeaders(ref responseHeaders, serverCon); // get the stream into which the message should be serialied from a stream handling // sink in the stream handling chain responseStream = GetResponseStreamFor(sinkStack, responseMsg, responseHeaders); m_messageHandler.SerialiseOutgoingLocateReplyMessage(response, deserReqMsg, msgInput.Header.Version, responseStream, serverCon.ConDesc); return(ServerProcessing.Complete); }
/// <summary>reads an incoming Giop request-message from the Stream sourceStream</summary> /// <returns>the .NET request message created from this Giop-message</returns> internal IMessage ParseIncomingRequestMessage(Stream sourceStream, GiopConnectionDesc conDesc) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return(ParseIncomingRequestMessage(msgInput, conDesc)); }
/// <summary>reads an incoming Giop reply message from the Message input stream msgInput</summary> /// <remarks>Precondition: sourceStream contains a Giop reply Msg</remarks> /// <returns>the .NET reply Msg created from the Giop Reply</returns> internal IMessage ParseIncomingReplyMessage(CdrMessageInputStream msgInput, IMethodCallMessage requestMessage, GiopClientConnectionDesc conDesc) { Debug.WriteLine("receive reply message at client side"); CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); GiopClientRequest request = new GiopClientRequest(requestMessage, conDesc, m_interceptionOptions); if (request.IsAsyncRequest) { try { // with respec to interception, this is a new request -> call again send_request interception before reply request.PrepareSecondAscyncInterception(); request.InterceptSendRequest(); } catch (Exception ex) { request.Reply = new ReturnMessage(ex, requestMessage); Exception newException = request.InterceptReceiveException(ex); if (newException == ex) { throw; } else { throw newException; // exeption has been changed by interception point } } } // deserialize message body IMessage result = m_ser.DeserialiseReply(msgBody, msgInput.Header.Version, request, conDesc); return(result); }
/// <summary>reads an incoming Giop reply message from the Stream sourceStream</summary> /// <remarks>Precondition: sourceStream contains a Giop reply Msg</remarks> /// <returns>the .NET reply Msg created from the Giop Reply</returns> internal IMessage ParseIncomingReplyMessage(Stream sourceStream, IMethodCallMessage requestMessage, GiopClientConnectionDesc conDesc) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return(ParseIncomingReplyMessage(msgInput, requestMessage, conDesc)); }
/// <summary> /// reads a locate-request message. /// </summary> internal LocateRequestMessage ParseIncomingLocateRequestMessage(CdrMessageInputStream msgInput) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize message body LocateRequestMessage result = m_ser.DeserialiseLocateRequest(msgBody, msgInput.Header.Version); Debug.WriteLine("locate request for target-uri: " + result.TargetUri); return(result); }
/// <summary>reads an incoming Giop request-message from the message input stream msgInput</summary> /// <returns>the .NET request message created from this Giop-message</returns> internal IMessage ParseIncomingRequestMessage(CdrMessageInputStream msgInput, GiopConnectionDesc conDesc) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize the message body (the GIOP-request id is included in this message) return(m_ser.DeserialiseRequest(msgBody, msgInput.Header.Version, conDesc, m_interceptionOptions)); }
public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { responseMsg = null; responseHeaders = null; responseStream = null; CdrMessageInputStream msgInput = new CdrMessageInputStream(requestStream); GiopServerConnection serverCon = (GiopServerConnection) requestHeaders[GiopServerConnection.SERVER_TR_HEADER_KEY]; try { if (msgInput.Header.GiopType == GiopMsgTypes.Request) { return(ProcessRequestMessage(sinkStack, requestHeaders, msgInput, serverCon, out responseMsg, out responseHeaders, out responseStream)); } else if (msgInput.Header.GiopType == GiopMsgTypes.LocateRequest) { return(ProcessLocateRequestMessage(sinkStack, requestHeaders, msgInput, serverCon, out responseMsg, out responseHeaders, out responseStream)); } else { Trace.WriteLine("Processing problem on server connection after unexpected message of type " + msgInput.Header.GiopType); throw new NotSupportedException("wrong message type in server side formatter: " + msgInput.Header.GiopType); } } finally { try { requestStream.Close(); // not needed any more } catch { // ignore } } }
/// <summary> /// reads a locate-request message. /// </summary> internal LocateRequestMessage ParseIncomingLocateRequestMessage(Stream sourceStream) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return(ParseIncomingLocateRequestMessage(msgInput)); }
/// <summary>reads an incoming Giop reply message from the Stream sourceStream</summary> /// <remarks>Precondition: sourceStream contains a Giop reply Msg</remarks> /// <returns>the .NET reply Msg created from the Giop Reply</returns> internal IMessage ParseIncomingReplyMessage(Stream sourceStream, IMethodCallMessage requestMessage, GiopClientConnectionDesc conDesc) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return ParseIncomingReplyMessage(msgInput, requestMessage, conDesc); }
/// <summary> /// reads a locate-request message. /// </summary> internal LocateRequestMessage ParseIncomingLocateRequestMessage(CdrMessageInputStream msgInput) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize message body LocateRequestMessage result = m_ser.DeserialiseLocateRequest(msgBody, msgInput.Header.Version); Debug.WriteLine("locate request for target-uri: " + result.TargetUri); return result; }
/// <summary> /// process a giop request message. /// </summary> private ServerProcessing ProcessRequestMessage(IServerChannelSinkStack sinkStack, ITransportHeaders requestHeaders, CdrMessageInputStream msgInput, GiopServerConnection serverCon, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { IMessage deserReqMsg = null; responseHeaders = null; try { try { // deserialise the request deserReqMsg = m_messageHandler.ParseIncomingRequestMessage(msgInput, serverCon.ConDesc); } finally { //request deserialised -> safe to read next request while processing request in servant // (or sending request deserialisation exception) try { serverCon.NotifyDeserialiseRequestComplete(); } catch (Exception ne) { // unexpected exception. Abort message processing, problem with transport. throw new NotifyReadRequestException("Problem while trying to inform transport about request deserialistion.", ne); } } // processing may be done asynchronous, therefore push this sink on the stack to process a response async AsyncServerProcessingData asyncData = new AsyncServerProcessingData(deserReqMsg, serverCon); sinkStack.Push(this, asyncData); ServerProcessing processingResult; try { // forward the call to the next message handling sink processingResult = m_nextSink.ProcessMessage(sinkStack, deserReqMsg, requestHeaders, null, out responseMsg, out responseHeaders, out responseStream); } catch (Exception) { sinkStack.Pop(this); throw; } switch (processingResult) { case ServerProcessing.Complete: sinkStack.Pop(this); // not async // send the response SerialiseResponse(sinkStack, deserReqMsg, serverCon, responseMsg, ref responseHeaders, out responseStream); break; case ServerProcessing.Async: sinkStack.Store(this, asyncData); // this sink want's to process async response break; case ServerProcessing.OneWay: // nothing to do, because no response expected sinkStack.Pop(this); break; } return(processingResult); } catch (MessageHandling.RequestDeserializationException deserEx) { // exception from DeserialisRequest responseMsg = deserEx.ResponseMessage; // an exception was thrown during deserialization SerialiseExceptionResponse(sinkStack, deserEx.RequestMessage, serverCon, responseMsg, ref responseHeaders, out responseStream); return(ServerProcessing.Complete); } catch (NotifyReadRequestException nrre) { Trace.WriteLine("Failed to inform transport about request deserialisation. Processing problem on server connection after unexpected exception: " + nrre.InnerException); throw nrre; } catch (Exception e) { // serialise an exception response if (deserReqMsg != null) { if (deserReqMsg is IMethodCallMessage) { responseMsg = new ReturnMessage(e, (IMethodCallMessage)deserReqMsg); } else { responseMsg = new ReturnMessage(e, null); // no usable information present } SerialiseExceptionResponse(sinkStack, deserReqMsg, serverCon, responseMsg, ref responseHeaders, out responseStream); } else { throw e; } return(ServerProcessing.Complete); // send back an error msg } }
/// <summary>reads an incoming Giop request-message from the message input stream msgInput</summary> /// <returns>the .NET request message created from this Giop-message</returns> internal IMessage ParseIncomingRequestMessage(CdrMessageInputStream msgInput, GiopConnectionDesc conDesc) { CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); // deserialize the message body (the GIOP-request id is included in this message) return m_ser.DeserialiseRequest(msgBody, msgInput.Header.Version, conDesc, m_interceptionOptions); }
/// <summary> /// reads a locate-request message. /// </summary> internal LocateRequestMessage ParseIncomingLocateRequestMessage(Stream sourceStream) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return ParseIncomingLocateRequestMessage(msgInput); }
/// <summary>reads an incoming Giop request-message from the Stream sourceStream</summary> /// <returns>the .NET request message created from this Giop-message</returns> internal IMessage ParseIncomingRequestMessage(Stream sourceStream, GiopConnectionDesc conDesc) { CdrMessageInputStream msgInput = new CdrMessageInputStream(sourceStream); return ParseIncomingRequestMessage(msgInput, conDesc); }
/// <summary>reads an incoming Giop reply message from the Message input stream msgInput</summary> /// <remarks>Precondition: sourceStream contains a Giop reply Msg</remarks> /// <returns>the .NET reply Msg created from the Giop Reply</returns> internal IMessage ParseIncomingReplyMessage(CdrMessageInputStream msgInput, IMethodCallMessage requestMessage, GiopClientConnectionDesc conDesc) { Debug.WriteLine("receive reply message at client side"); CdrInputStream msgBody = msgInput.GetMessageContentReadingStream(); GiopClientRequest request = new GiopClientRequest(requestMessage, conDesc, m_interceptionOptions); if (request.IsAsyncRequest) { try { // with respec to interception, this is a new request -> call again send_request interception before reply request.PrepareSecondAscyncInterception(); request.InterceptSendRequest(); } catch (Exception ex) { request.Reply = new ReturnMessage(ex, requestMessage); Exception newException = request.InterceptReceiveException(ex); if (newException == ex) { throw; } else { throw newException; // exeption has been changed by interception point } } } // deserialize message body IMessage result = m_ser.DeserialiseReply(msgBody, msgInput.Header.Version, request, conDesc); return result; }
/// <summary> /// process a giop request message. /// </summary> private ServerProcessing ProcessRequestMessage(IServerChannelSinkStack sinkStack, ITransportHeaders requestHeaders, CdrMessageInputStream msgInput, GiopServerConnection serverCon, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { IMessage deserReqMsg = null; responseHeaders = null; try { try { // deserialise the request deserReqMsg = m_messageHandler.ParseIncomingRequestMessage(msgInput, serverCon.ConDesc); } finally { //request deserialised -> safe to read next request while processing request in servant // (or sending request deserialisation exception) try { serverCon.NotifyDeserialiseRequestComplete(); } catch (Exception ne) { // unexpected exception. Abort message processing, problem with transport. throw new NotifyReadRequestException("Problem while trying to inform transport about request deserialistion.", ne); } } // processing may be done asynchronous, therefore push this sink on the stack to process a response async AsyncServerProcessingData asyncData = new AsyncServerProcessingData(deserReqMsg, serverCon); sinkStack.Push(this, asyncData); ServerProcessing processingResult; try { // forward the call to the next message handling sink processingResult = m_nextSink.ProcessMessage(sinkStack, deserReqMsg, requestHeaders, null, out responseMsg, out responseHeaders, out responseStream); } catch (Exception) { sinkStack.Pop(this); throw; } switch (processingResult) { case ServerProcessing.Complete: sinkStack.Pop(this); // not async // send the response SerialiseResponse(sinkStack, deserReqMsg, serverCon, responseMsg, ref responseHeaders, out responseStream); break; case ServerProcessing.Async: sinkStack.Store(this, asyncData); // this sink want's to process async response break; case ServerProcessing.OneWay: // nothing to do, because no response expected sinkStack.Pop(this); break; } return processingResult; } catch (MessageHandling.RequestDeserializationException deserEx) { // exception from DeserialisRequest responseMsg = deserEx.ResponseMessage; // an exception was thrown during deserialization SerialiseExceptionResponse(sinkStack, deserEx.RequestMessage, serverCon, responseMsg, ref responseHeaders, out responseStream); return ServerProcessing.Complete; } catch (NotifyReadRequestException nrre) { Trace.WriteLine("Failed to inform transport about request deserialisation. Processing problem on server connection after unexpected exception: " + nrre.InnerException); throw nrre; } catch (Exception e) { // serialise an exception response if (deserReqMsg != null) { if (deserReqMsg is IMethodCallMessage) { responseMsg = new ReturnMessage(e, (IMethodCallMessage) deserReqMsg); } else { responseMsg = new ReturnMessage(e, null); // no usable information present } SerialiseExceptionResponse(sinkStack, deserReqMsg, serverCon, responseMsg, ref responseHeaders, out responseStream); } else { throw e; } return ServerProcessing.Complete; // send back an error msg } }
public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { responseMsg = null; responseHeaders = null; responseStream = null; CdrMessageInputStream msgInput = new CdrMessageInputStream(requestStream); GiopServerConnection serverCon = (GiopServerConnection) requestHeaders[GiopServerConnection.SERVER_TR_HEADER_KEY]; try { if (msgInput.Header.GiopType == GiopMsgTypes.Request) { return ProcessRequestMessage(sinkStack, requestHeaders, msgInput, serverCon, out responseMsg, out responseHeaders, out responseStream); } else if (msgInput.Header.GiopType == GiopMsgTypes.LocateRequest) { return ProcessLocateRequestMessage(sinkStack, requestHeaders, msgInput, serverCon, out responseMsg, out responseHeaders, out responseStream); } else { Trace.WriteLine("Processing problem on server connection after unexpected message of type " + msgInput.Header.GiopType); throw new NotSupportedException("wrong message type in server side formatter: " + msgInput.Header.GiopType); } } finally { try { requestStream.Close(); // not needed any more } catch { // ignore } } }
/// <summary> /// process a giop locate request message. /// </summary> private ServerProcessing ProcessLocateRequestMessage(IServerChannelSinkStack sinkStack, ITransportHeaders requestHeaders, CdrMessageInputStream msgInput, GiopServerConnection serverCon, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { responseHeaders = null; LocateRequestMessage deserReqMsg = m_messageHandler.ParseIncomingLocateRequestMessage(msgInput); // TODO: dummy implementation, don't check yet LocateReplyMessage response = new LocateReplyMessage(LocateStatus.OBJECT_HERE); responseMsg = response; PrepareResponseHeaders(ref responseHeaders, serverCon); // get the stream into which the message should be serialied from a stream handling // sink in the stream handling chain responseStream = GetResponseStreamFor(sinkStack, responseMsg, responseHeaders); m_messageHandler.SerialiseOutgoingLocateReplyMessage(response, deserReqMsg, msgInput.Header.Version, responseStream, serverCon.ConDesc); return ServerProcessing.Complete; }