public override void Invoke(AMFContext context) { AMFSerializer serializer = new AMFSerializer(context.OutputStream); serializer.UseLegacyCollection = _useLegacyCollection; serializer.UseLegacyThrowable = _useLegacyThrowable; serializer.WriteMessage(context.MessageOutput); serializer.Flush(); //Serialization/deserialization debugging //Note: this will not work correctly with optimizers (different ClassDefinitions from server and client) /* MemoryStream ms = new MemoryStream(); AMFSerializer testSerializer = new AMFSerializer(ms); testSerializer.UseLegacyCollection = _useLegacyCollection; testSerializer.UseLegacyThrowable = _useLegacyThrowable; testSerializer.WriteMessage(context.MessageOutput); testSerializer.Flush(); ms.Position = 0; AMFDeserializer testDeserializer = new AMFDeserializer(ms); testDeserializer.UseLegacyCollection = _useLegacyCollection; AMFMessage amfMessageOut = testDeserializer.ReadAMFMessage(); ms.Position = 0; byte[] buffer = ms.ToArray(); context.OutputStream.Write(buffer, 0, buffer.Length); */ }
public override void Invoke(AMFContext context) { for(int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); if( !amfBody.IsEmptyTarget ) {//Flash if( FluorineConfiguration.Instance.ServiceMap != null ) { string typeName = amfBody.TypeName; string method = amfBody.Method; if( typeName != null && FluorineConfiguration.Instance.ServiceMap.Contains(typeName) ) { string serviceLocation = FluorineConfiguration.Instance.ServiceMap.GetServiceLocation(typeName); method = FluorineConfiguration.Instance.ServiceMap.GetMethod(typeName, method); string target = serviceLocation + "." + method; if( log != null && log.IsDebugEnabled ) log.Debug(__Res.GetString(__Res.Service_Mapping, amfBody.Target, target)); amfBody.Target = target; } } } } }
public override void Invoke(AMFContext context) { AMFMessage amfMessage = context.AMFMessage; AMFHeader amfHeader = amfMessage.GetHeader( AMFHeader.ServiceBrowserHeader ); if( amfHeader != null ) { AMFBody amfBody = amfMessage.GetBodyAt(0); amfBody.IsDescribeService = true; } }
public override void Invoke(AMFContext context) { AMFMessage amfMessage = context.AMFMessage; AMFHeader amfHeader = amfMessage.GetHeader( AMFHeader.DebugHeader ); if( amfHeader != null ) { //The value of the header ASObject asObject = amfHeader.Content as ASObject; //["error"]: {true} //["trace"]: {true} //["httpheaders"]: {false} //["coldfusion"]: {true} //["amf"]: {false} //["m_debug"]: {true} //["amfheaders"]: {false} //["recordset"]: {true} AMFBody amfBody = amfMessage.GetBodyAt(amfMessage.BodyCount-1);//last body ResponseBody amfBodyOut = new ResponseBody(); amfBodyOut.Target = amfBody.Response + AMFBody.OnDebugEvents; amfBodyOut.Response = null; amfBodyOut.IsDebug = true; ArrayList headerResults = new ArrayList(); ArrayList result = new ArrayList(); headerResults.Add( result ); if( (bool)asObject["httpheaders"] == true ) { //If the client wants http headers result.Add( new HttpHeader( ) ); } if( (bool)asObject["amfheaders"] == true ) { result.Add( new AMFRequestHeaders( amfMessage ) ); } ArrayList traceStack = NetDebug.GetTraceStack(); if( (bool)asObject["trace"] == true && traceStack != null && traceStack.Count > 0 ) { ArrayList tmp = new ArrayList( traceStack ); result.Add( new TraceHeader( tmp ) ); NetDebug.Clear(); } //http://osflash.org/amf/envelopes/remoting/debuginfo amfBodyOut.Content = headerResults; context.MessageOutput.AddBody(amfBodyOut); } NetDebug.Clear(); }
public override void Invoke(AMFContext context) { AMFDeserializer deserializer = new AMFDeserializer(context.InputStream); deserializer.UseLegacyCollection = _useLegacyCollection; try { AMFMessage amfMessage = deserializer.ReadAMFMessage(); context.AMFMessage = amfMessage; context.MessageOutput = new MessageOutput(amfMessage.Version); if (deserializer.FailedAMFBodies.Length > 0) { AMFBody[] failedAMFBodies = deserializer.FailedAMFBodies; //Write out failed AMFBodies for (int i = 0; i < failedAMFBodies.Length; i++) context.MessageOutput.AddBody(failedAMFBodies[i]); } } catch { Dump(context.InputStream); throw; } }
public override void Invoke(AMFContext context) { MessageOutput messageOutput = context.MessageOutput; if( FluorineConfiguration.Instance.CacheMap != null && FluorineConfiguration.Instance.CacheMap.Count > 0 ) { for(int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); //Check if response exists. ResponseBody responseBody = messageOutput.GetResponse(amfBody); if( responseBody != null ) { //AuthenticationFilter may insert response. continue; } if( !amfBody.IsEmptyTarget ) { string source = amfBody.Target; IList arguments = amfBody.GetParameterList(); string key = dotFlex.Configuration.CacheMap.GenerateCacheKey(source, arguments); //Flash message if( FluorineConfiguration.Instance.CacheMap.ContainsValue(key) ) { object cachedContent = FluorineConfiguration.Instance.CacheMap.Get(key); if( log != null && log.IsDebugEnabled ) log.Debug( __Res.GetString(__Res.Cache_HitKey, amfBody.Target, key)); CachedBody cachedBody = new CachedBody(amfBody, cachedContent); messageOutput.AddBody(cachedBody); } } } } }
public override void Invoke(AMFContext context) { MessageOutput messageOutput = context.MessageOutput; for (int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); //Check for Flex2 messages if (amfBody.IsEmptyTarget) { object content = amfBody.Content; if (content is IList) content = (content as IList)[0]; IMessage message = content as IMessage; if (message != null) { Client client = null; HttpSession session = null; if (FluorineContext.Current.Client == null) { IClientRegistry clientRegistry = _endpoint.GetMessageBroker().ClientRegistry; string clientId = message.GetFlexClientId(); if (!clientRegistry.HasClient(clientId)) { lock (clientRegistry.SyncRoot) { if (!clientRegistry.HasClient(clientId)) { client = _endpoint.GetMessageBroker().ClientRegistry.GetClient(clientId) as Client; } } } if (client == null) client = _endpoint.GetMessageBroker().ClientRegistry.GetClient(clientId) as Client; FluorineContext.Current.SetClient(client); } session = _endpoint.GetMessageBroker().SessionManager.GetHttpSession(HttpContext.Current); FluorineContext.Current.SetSession(session); //Context initialized, notify listeners. if (session != null && session.IsNew) session.NotifyCreated(); if (client != null) { if (session != null) client.RegisterSession(session); if (client.IsNew) { client.Renew(_endpoint.ClientLeaseTime); client.NotifyCreated(); } } /* RemotingConnection remotingConnection = null; foreach (IConnection connection in client.Connections) { if (connection is RemotingConnection) { remotingConnection = connection as RemotingConnection; break; } } if (remotingConnection == null) { remotingConnection = new RemotingConnection(_endpoint, null, client.Id, null); remotingConnection.Initialize(client, session); } FluorineContext.Current.SetConnection(remotingConnection); */ } } else { //Flash remoting AMFHeader amfHeader = context.AMFMessage.GetHeader(AMFHeader.AMFDSIdHeader); string amfDSId = null; if (amfHeader == null ) { amfDSId = Guid.NewGuid().ToString("D"); ASObject asoObjectDSId = new ASObject(); asoObjectDSId["name"] = AMFHeader.AMFDSIdHeader; asoObjectDSId["mustUnderstand"] = false; asoObjectDSId["data"] = amfDSId;//set AMFHeader headerDSId = new AMFHeader(AMFHeader.RequestPersistentHeader, true, asoObjectDSId); context.MessageOutput.AddHeader(headerDSId); } else amfDSId = amfHeader.Content as string; Client client = null; HttpSession session = null; if (FluorineContext.Current.Client == null) { IClientRegistry clientRegistry = _endpoint.GetMessageBroker().ClientRegistry; string clientId = amfDSId; if (!clientRegistry.HasClient(clientId)) { lock (clientRegistry.SyncRoot) { if (!clientRegistry.HasClient(clientId)) { client = _endpoint.GetMessageBroker().ClientRegistry.GetClient(clientId) as Client; } } } if (client == null) client = _endpoint.GetMessageBroker().ClientRegistry.GetClient(clientId) as Client; } FluorineContext.Current.SetClient(client); session = _endpoint.GetMessageBroker().SessionManager.GetHttpSession(HttpContext.Current); FluorineContext.Current.SetSession(session); //Context initialized, notify listeners. if (session != null && session.IsNew) session.NotifyCreated(); if (client != null) { if (session != null) client.RegisterSession(session); if (client.IsNew) { client.Renew(_endpoint.ClientLeaseTime); client.NotifyCreated(); } } } } }
public override void Invoke(AMFContext context) { MessageBroker messageBroker = _endpoint.GetMessageBroker(); try { AMFHeader amfHeader = context.AMFMessage.GetHeader(AMFHeader.CredentialsHeader); if (amfHeader != null && amfHeader.Content != null) { string userId = ((ASObject)amfHeader.Content)["userid"] as string; string password = ((ASObject)amfHeader.Content)["password"] as string; //Clear credentials header, further requests will not send the credentials ASObject asoObject = new ASObject(); asoObject["name"] = AMFHeader.CredentialsHeader; asoObject["mustUnderstand"] = false; asoObject["data"] = null;//clear AMFHeader header = new AMFHeader(AMFHeader.RequestPersistentHeader, true, asoObject); context.MessageOutput.AddHeader(header); IPrincipal principal = _endpoint.GetMessageBroker().LoginManager.Login(userId, amfHeader.Content as IDictionary); string key = EncryptCredentials(_endpoint, principal, userId, password); ASObject asoObjectCredentialsId = new ASObject(); asoObjectCredentialsId["name"] = AMFHeader.CredentialsIdHeader; asoObjectCredentialsId["mustUnderstand"] = false; asoObjectCredentialsId["data"] = key;//set AMFHeader headerCredentialsId = new AMFHeader(AMFHeader.RequestPersistentHeader, true, asoObjectCredentialsId); context.MessageOutput.AddHeader(headerCredentialsId); } else { amfHeader = context.AMFMessage.GetHeader(AMFHeader.CredentialsIdHeader); if (amfHeader != null) { string key = amfHeader.Content as string; if (key != null) _endpoint.GetMessageBroker().LoginManager.RestorePrincipal(key); } else { _endpoint.GetMessageBroker().LoginManager.RestorePrincipal(); } } } catch (UnauthorizedAccessException exception) { for (int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception); context.MessageOutput.AddBody(errorResponseBody); } } catch (Exception exception) { if (log != null && log.IsErrorEnabled) log.Error(exception.Message, exception); for (int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception); context.MessageOutput.AddBody(errorResponseBody); } } }
public override void Service() { //AMFContext amfContext = new AMFContext(HttpContext.Current.Request.InputStream, HttpContext.Current.Response.OutputStream); AMFContext amfContext = null; if (FluorineConfiguration.Instance.FluorineSettings.Debug != null && FluorineConfiguration.Instance.FluorineSettings.Debug.Mode != Debug.Off) { MemoryStream ms = new MemoryStream(); int bufferSize = 255; byte[] buffer = new byte[bufferSize]; int byteCount = 0; while ((byteCount = HttpContext.Current.Request.InputStream.Read(buffer, 0, bufferSize)) > 0) { ms.Write(buffer, 0, byteCount); } ms.Seek(0, SeekOrigin.Begin); amfContext = new AMFContext(ms, HttpContext.Current.Response.OutputStream); } if( amfContext == null ) amfContext = new AMFContext(HttpContext.Current.Request.InputStream, HttpContext.Current.Response.OutputStream); AMFContext.Current = amfContext; _filterChain.InvokeFilters(amfContext); }
public override void Invoke(AMFContext context) { MessageOutput messageOutput = context.MessageOutput; for(int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); ResponseBody responseBody = null; //Check for Flex2 messages and skip if( amfBody.IsEmptyTarget ) continue; if( amfBody.IsDebug ) continue; if( amfBody.IsDescribeService ) { responseBody = new ResponseBody(); responseBody.IgnoreResults = amfBody.IgnoreResults; responseBody.Target = amfBody.Response + AMFBody.OnResult; responseBody.Response = null; DescribeService describeService = new DescribeService( amfBody ); responseBody.Content = describeService.GetDescription(); messageOutput.AddBody(responseBody); continue; } //Check if response exists. responseBody = messageOutput.GetResponse(amfBody); if( responseBody != null ) { continue; } try { MessageBroker messageBroker = _endpoint.GetMessageBroker(); RemotingService remotingService = messageBroker.GetService(RemotingService.RemotingServiceId) as RemotingService; if (remotingService == null) { string serviceNotFound = __Res.GetString(__Res.Service_NotFound, RemotingService.RemotingServiceId); responseBody = new ErrorResponseBody(amfBody, new FluorineException(serviceNotFound)); messageOutput.AddBody(responseBody); if (log.IsErrorEnabled) log.Error(serviceNotFound); continue; } Destination destination = null; if (destination == null) destination = remotingService.GetDestinationWithSource(amfBody.TypeName); if (destination == null) destination = remotingService.DefaultDestination; //At this moment we got a destination with the exact source or we have a default destination with the "*" source. if (destination == null) { string destinationNotFound = __Res.GetString(__Res.Destination_NotFound, amfBody.TypeName); responseBody = new ErrorResponseBody(amfBody, new FluorineException(destinationNotFound)); messageOutput.AddBody(responseBody); if (log.IsErrorEnabled) log.Error(destinationNotFound); continue; } try { remotingService.CheckSecurity(destination); } catch (UnauthorizedAccessException exception) { responseBody = new ErrorResponseBody(amfBody, exception); if (log.IsDebugEnabled) log.Debug(exception.Message); continue; } //Cache check string source = amfBody.TypeName + "." + amfBody.Method; IList parameterList = amfBody.GetParameterList(); string key = dotFlex.Configuration.CacheMap.GenerateCacheKey(source, parameterList); if (FluorineConfiguration.Instance.CacheMap.ContainsValue(key)) { object result = dotFlex.Configuration.FluorineConfiguration.Instance.CacheMap.Get(key); if (result != null) { if (log != null && log.IsDebugEnabled) log.Debug(__Res.GetString(__Res.Cache_HitKey, source, key)); responseBody = new ResponseBody(amfBody, result); messageOutput.AddBody(responseBody); continue; } } FactoryInstance factoryInstance = destination.GetFactoryInstance(); factoryInstance.Source = amfBody.TypeName; if( FluorineContext.Current.ActivationMode != null )//query string can override the activation mode factoryInstance.Scope = FluorineContext.Current.ActivationMode; object instance = factoryInstance.Lookup(); if( instance != null ) { try { bool isAccessible = TypeHelper.GetTypeIsAccessible(instance.GetType()); if (!isAccessible) { string msg = __Res.GetString(__Res.Type_InitError, amfBody.TypeName); if (log.IsErrorEnabled) log.Error(msg); responseBody = new ErrorResponseBody(amfBody, new FluorineException(msg)); messageOutput.AddBody(responseBody); continue; } MethodInfo mi = null; if (!amfBody.IsRecordsetDelivery) { mi = MethodHandler.GetMethod(instance.GetType(), amfBody.Method, amfBody.GetParameterList()); } else { //will receive recordsetid only (ignore) mi = instance.GetType().GetMethod(amfBody.Method); } if (mi != null) { object[] roleAttributes = mi.GetCustomAttributes(typeof(RoleAttribute), true); if (roleAttributes != null && roleAttributes.Length == 1) { RoleAttribute roleAttribute = roleAttributes[0] as RoleAttribute; string[] roles = roleAttribute.Roles.Split(','); bool authorized = messageBroker.LoginManager.DoAuthorization(roles); if (!authorized) throw new UnauthorizedAccessException(__Res.GetString(__Res.Security_AccessNotAllowed)); } #region Invocation handling PageSizeAttribute pageSizeAttribute = null; MethodInfo miCounter = null; object[] pageSizeAttributes = mi.GetCustomAttributes(typeof(PageSizeAttribute), true); if (pageSizeAttributes != null && pageSizeAttributes.Length == 1) { pageSizeAttribute = pageSizeAttributes[0] as PageSizeAttribute; miCounter = instance.GetType().GetMethod(amfBody.Method + "Count"); if (miCounter != null && miCounter.ReturnType != typeof(System.Int32)) miCounter = null; //check signature } ParameterInfo[] parameterInfos = mi.GetParameters(); //Try to handle missing/optional parameters. object[] args = new object[parameterInfos.Length]; if (!amfBody.IsRecordsetDelivery) { if (args.Length != parameterList.Count) { string msg = __Res.GetString(__Res.Arg_Mismatch, parameterList.Count, mi.Name, args.Length); if (log != null && log.IsErrorEnabled) log.Error(msg); responseBody = new ErrorResponseBody(amfBody, new ArgumentException(msg)); messageOutput.AddBody(responseBody); continue; } parameterList.CopyTo(args, 0); if (pageSizeAttribute != null) { PagingContext pagingContext = new PagingContext(pageSizeAttribute.Offset, pageSizeAttribute.Limit); PagingContext.SetPagingContext(pagingContext); } } else { if (amfBody.Target.EndsWith(".release")) { responseBody = new ResponseBody(amfBody, null); messageOutput.AddBody(responseBody); continue; } string recordsetId = parameterList[0] as string; string recordetDeliveryParameters = amfBody.GetRecordsetArgs(); byte[] buffer = System.Convert.FromBase64String(recordetDeliveryParameters); recordetDeliveryParameters = System.Text.Encoding.UTF8.GetString(buffer); if (recordetDeliveryParameters != null && recordetDeliveryParameters != string.Empty) { string[] stringParameters = recordetDeliveryParameters.Split(new char[] { ',' }); for (int j = 0; j < stringParameters.Length; j++) { if (stringParameters[j] == string.Empty) args[j] = null; else args[j] = stringParameters[j]; } //TypeHelper.NarrowValues(argsStore, parameterInfos); } PagingContext pagingContext = new PagingContext(System.Convert.ToInt32(parameterList[1]), System.Convert.ToInt32(parameterList[2])); PagingContext.SetPagingContext(pagingContext); } TypeHelper.NarrowValues(args, parameterInfos); try { InvocationHandler invocationHandler = new InvocationHandler(mi); object result = invocationHandler.Invoke(instance, args); if (FluorineConfiguration.Instance.CacheMap != null && FluorineConfiguration.Instance.CacheMap.ContainsCacheDescriptor(source)) { //The result should be cached CacheableObject cacheableObject = new CacheableObject(source, key, result); FluorineConfiguration.Instance.CacheMap.Add(cacheableObject.Source, cacheableObject.CacheKey, cacheableObject); result = cacheableObject; } responseBody = new ResponseBody(amfBody, result); if (pageSizeAttribute != null) { int totalCount = 0; string recordsetId = null; IList list = amfBody.GetParameterList(); string recordetDeliveryParameters = null; if (!amfBody.IsRecordsetDelivery) { //fist call paging object[] argsStore = new object[list.Count]; list.CopyTo(argsStore, 0); recordsetId = System.Guid.NewGuid().ToString(); if (miCounter != null) { //object[] counterArgs = new object[0]; totalCount = (int)miCounter.Invoke(instance, args); } string[] stringParameters = new string[argsStore.Length]; for (int j = 0; j < argsStore.Length; j++) { if (argsStore[j] != null) stringParameters[j] = argsStore[j].ToString(); else stringParameters[j] = string.Empty; } recordetDeliveryParameters = string.Join(",", stringParameters); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(recordetDeliveryParameters); recordetDeliveryParameters = System.Convert.ToBase64String(buffer); } else { recordsetId = amfBody.GetParameterList()[0] as string; } if (result is DataTable) { DataTable dataTable = result as DataTable; dataTable.ExtendedProperties["TotalCount"] = totalCount; dataTable.ExtendedProperties["Service"] = recordetDeliveryParameters + "/" + amfBody.Target; dataTable.ExtendedProperties["RecordsetId"] = recordsetId; if (amfBody.IsRecordsetDelivery) { dataTable.ExtendedProperties["Cursor"] = Convert.ToInt32(list[list.Count - 2]); dataTable.ExtendedProperties["DynamicPage"] = true; } } } } catch (UnauthorizedAccessException exception) { responseBody = new ErrorResponseBody(amfBody, exception); if (log.IsDebugEnabled) log.Debug(exception.Message); } catch (Exception exception) { if (exception is TargetInvocationException && exception.InnerException != null) responseBody = new ErrorResponseBody(amfBody, exception.InnerException); else responseBody = new ErrorResponseBody(amfBody, exception); if (log.IsDebugEnabled) log.Debug(__Res.GetString(__Res.Invocation_Failed, mi.Name, exception.Message)); } #endregion Invocation handling } else responseBody = new ErrorResponseBody(amfBody, new MissingMethodException(amfBody.TypeName, amfBody.Method)); } finally { factoryInstance.OnOperationComplete(instance); } } else responseBody = new ErrorResponseBody(amfBody, new TypeInitializationException(amfBody.TypeName, null)); } catch(Exception exception) { if( log != null && log.IsErrorEnabled ) log.Error(exception.Message, exception); responseBody = new ErrorResponseBody(amfBody, exception); } messageOutput.AddBody(responseBody); } }
public override void Invoke(AMFContext context) { MessageOutput messageOutput = context.MessageOutput; for(int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); if( !amfBody.IsEmptyTarget ) continue; object content = amfBody.Content; if( content is IList ) content = (content as IList)[0]; IMessage message = content as IMessage; //Check for Flex2 messages and handle if( message != null ) { //if (FluorineContext.Current.Client == null) // FluorineContext.Current.SetCurrentClient(_endpoint.GetMessageBroker().ClientRegistry.GetClient(message)); if(message.clientId == null) message.clientId = Guid.NewGuid().ToString("D"); //Check if response exists. ResponseBody responseBody = messageOutput.GetResponse(amfBody); if( responseBody != null ) { continue; } try { if (context.AMFMessage.BodyCount > 1) { CommandMessage commandMessage = message as CommandMessage; //Suppress poll wait if there are more messages to process if (commandMessage != null && commandMessage.operation == CommandMessage.PollOperation ) commandMessage.SetHeader(CommandMessage.FluorineSuppressPollWaitHeader, null); } IMessage resultMessage = _endpoint.ServiceMessage(message); if (resultMessage is ErrorMessage) { ErrorMessage errorMessage = resultMessage as ErrorMessage; responseBody = new ErrorResponseBody(amfBody, message, resultMessage as ErrorMessage); if (errorMessage.faultCode == ErrorMessage.ClientAuthenticationError) { messageOutput.AddBody(responseBody); for (int j = i + 1; j < context.AMFMessage.BodyCount; j++) { amfBody = context.AMFMessage.GetBodyAt(j); if (!amfBody.IsEmptyTarget) continue; content = amfBody.Content; if (content is IList) content = (content as IList)[0]; message = content as IMessage; //Check for Flex2 messages and handle if (message != null) { responseBody = new ErrorResponseBody(amfBody, message, new SecurityException(errorMessage.faultString)); messageOutput.AddBody(responseBody); } } //Leave further processing return; } } else { responseBody = new ResponseBody(amfBody, resultMessage); } } catch(Exception exception) { if( log != null && log.IsErrorEnabled ) log.Error(exception.Message, exception); responseBody = new ErrorResponseBody(amfBody, message, exception); } messageOutput.AddBody(responseBody); } } }
public override void Invoke(AMFContext context) { for(int i = 0; i < context.AMFMessage.BodyCount; i++) { AMFBody amfBody = context.AMFMessage.GetBodyAt(i); if (!amfBody.IsEmptyTarget) { if (amfBody.IsWebService) { try { Type type = GetTypeForWebService(amfBody.TypeName); if (type != null) { //We can handle it with a LibraryAdapter now amfBody.Target = type.FullName + "." + amfBody.Method; } else { Exception exception = new TypeInitializationException(amfBody.TypeName, null); if (log != null && log.IsErrorEnabled) log.Error(__Res.GetString(__Res.Type_InitError, amfBody.Target), exception); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception); context.MessageOutput.AddBody(errorResponseBody); } } catch (Exception exception) { if (log != null && log.IsErrorEnabled) log.Error(__Res.GetString(__Res.Wsdl_ProxyGen, amfBody.Target), exception); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception); context.MessageOutput.AddBody(errorResponseBody); } } } else { //Flex message object content = amfBody.Content; if (content is IList) content = (content as IList)[0]; IMessage message = content as IMessage; if (message != null && message is RemotingMessage) { RemotingMessage remotingMessage = message as RemotingMessage; //Only RemotingMessages for now string source = remotingMessage.source; if (source != null && source.ToLower().EndsWith(".asmx")) { try { Type type = GetTypeForWebService(source); if (type != null) { //We can handle it with a LibraryAdapter now remotingMessage.source = type.FullName; } else { Exception exception = new TypeInitializationException(source, null); if (log != null && log.IsErrorEnabled) log.Error(__Res.GetString(__Res.Type_InitError, source), exception); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, message, exception); context.MessageOutput.AddBody(errorResponseBody); } } catch (Exception exception) { if (log != null && log.IsErrorEnabled) log.Error(__Res.GetString(__Res.Wsdl_ProxyGen, source), exception); ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, message, exception); context.MessageOutput.AddBody(errorResponseBody); } } } } } }
public virtual void Invoke(AMFContext context) { }