private void InitalizeForInterception(IInterceptionOption[] interceptionOptions) { // flow lifetime is bound to message lifetime, GiopServerRequest is only a wrapper around message and // can be recreated during message lifetime. m_interceptionFlow = (ServerRequestInterceptionFlow)SimpleGiopMsg.GetInterceptionFlow(m_requestMessage); if (m_interceptionFlow == null) { ServerRequestInterceptor[] interceptors = OrbServices.GetSingleton().InterceptorManager.GetServerRequestInterceptors(interceptionOptions); if (interceptors.Length == 0) { m_interceptionFlow = new ServerRequestInterceptionFlow(); } else { m_interceptionFlow = new ServerRequestInterceptionFlow(interceptors); } SimpleGiopMsg.SetInterceptionFlow(m_requestMessage, m_interceptionFlow); } if (m_interceptionFlow.NeedsRequestInfo()) { m_serverRequestInfo = new ServerRequestInfoImpl(this); } }
/// <summary> /// constructor for the out-direction /// </summary> /// <param name="request">the request message, may be null</param> /// <param name="reply">the reply message</param> internal GiopServerRequest(IMessage request, ReturnMessage reply, GiopConnectionDesc conDesc, IInterceptionOption[] interceptionOptions) { if (request is IMethodCallMessage) { m_requestCallMessage = (IMethodCallMessage)request; } m_requestMessage = request; m_replyMessage = reply; m_conDesc = conDesc; InitalizeForInterception(interceptionOptions); }
/// <summary> /// constructor for the in direction. /// </summary> internal GiopServerRequest(GiopConnectionDesc conDesc, IInterceptionOption[] interceptionOptions) { m_requestMessage = new SimpleGiopMsg(); m_requestCallMessage = null; // not yet created; will be created from requestMessage later. m_replyMessage = null; // not yet available m_conDesc = conDesc; InitalizeForInterception(interceptionOptions); }
internal GiopClientRequest(IMethodCallMessage requestMsg, GiopClientConnectionDesc conDesc, IInterceptionOption[] interceptionOptions) { m_requestMessage = requestMsg; m_conDesc = conDesc; IntializeForInterception(interceptionOptions); }
/// <summary> /// Constructs a giop message handler, which uses the given /// ArgumentsSerializerFactory for serializing/deserializing /// requests/replys. The headerFlags parameter defines the /// used header flags for messages initiated by this handler. /// The interceptionOptions[] provides the information on /// channel level interceptors. /// </summary> internal GiopMessageHandler(ArgumentsSerializerFactory argSerFactory, byte headerFlags, IInterceptionOption[] interceptionOptions) { m_ser = new GiopMessageBodySerialiser(argSerFactory); m_headerFlags = headerFlags; m_interceptionOptions = interceptionOptions; }
/// <summary> /// Deserialises the Giop Message body for a request /// </summary> /// <param name="cdrStream"></param> /// <param name="version"></param> /// <returns></returns> internal IMessage DeserialiseRequest(CdrInputStream cdrStream, GiopVersion version, GiopConnectionDesc conDesc, IInterceptionOption[] interceptionOptions) { MethodCall methodCallInfo = null; GiopServerRequest serverRequest = new GiopServerRequest(conDesc, interceptionOptions); serverRequest.Version = version; try { ServiceContextList cntxColl = null; if (version.IsBeforeGiop1_2()) { // GIOP 1.0 / 1.1 cntxColl = DeserialiseContext(cdrStream); // Service context deser } // read the request-ID and set it as a message property uint requestId = cdrStream.ReadULong(); serverRequest.RequestId = requestId; Trace.WriteLine("received a message with reqId: " + requestId); // read response-flags: byte respFlags = cdrStream.ReadOctet(); Debug.WriteLine("response-flags: " + respFlags); cdrStream.ReadPadding(3); // read reserved bytes serverRequest.ResponseFlags = respFlags; // decode the target of this request byte[] objectKey; serverRequest.RequestUri = ReadTarget(cdrStream, version, out objectKey); serverRequest.ObjectKey = objectKey; serverRequest.RequestMethodName = cdrStream.ReadString(); Trace.WriteLine("call for .NET object: " + serverRequest.RequestUri + ", methodName: " + serverRequest.RequestMethodName); if (version.IsBeforeGiop1_2()) { // GIOP 1.0 / 1.1 uint principalLength = cdrStream.ReadULong(); cdrStream.ReadOpaque((int)principalLength); } else { cntxColl = DeserialiseContext(cdrStream); // Service context deser } PerformCodeSetEstablishmentServer(version, conDesc, cntxColl); // set codeset for stream SetCodeSet(cdrStream, conDesc); // request header deserialised serverRequest.RequestServiceContext = cntxColl; serverRequest.InterceptReceiveRequestServiceContexts(); serverRequest.SetThreadScopeCurrentFromPICurrent(); // copy request scope picurrent to thread scope pi-current serverRequest.ResolveTargetType(); // determine the .net target object type and check if target object is available ArgumentsSerializer argSer = m_argSerFactory.Create(serverRequest.ServerTypeType); MethodInfo called = argSer.GetMethodInfoFor(serverRequest.RequestMethodName); serverRequest.ResolveCalledMethod(called); // set target method and handle special cases IDictionary contextElements; DeserialiseRequestBody(cdrStream, version, serverRequest, argSer, out contextElements); methodCallInfo = new MethodCall(serverRequest.Request); if (contextElements != null) { AddContextElementsToCallContext(methodCallInfo.LogicalCallContext, contextElements); } serverRequest.UpdateWithFinalRequest(methodCallInfo); serverRequest.InterceptReceiveRequest(); // all information now available return methodCallInfo; } catch (Exception e) { // an Exception encountered during deserialisation try { cdrStream.SkipRest(); // skip rest of the message, to not corrupt the stream } catch (Exception) { // ignore exception here, already an other exception leading to problems } ReturnMessage exceptionResponse; exceptionResponse = new ReturnMessage(e, methodCallInfo); throw new RequestDeserializationException(e, serverRequest.Request, exceptionResponse); // send exception interception point will be called when serialising exception response } }