Пример #1
0
        public override V3Message execute(Request message, RequestContext context)
        {
            String       dsId    = (String)this.headers["DSId"];
            String       woId    = (String)this.headers["WebORBClientId"];
            IDestination destObj = ORBConfig.GetInstance().GetDataServices().GetDestinationManager().GetDestination(destination);

            if (Log.isLogging(LoggingConstants.INFO))
            {
                Log.log(LoggingConstants.INFO, "Delivering message to destination " + destination);
            }

            if (messageId == null)
            {
                messageId = Guid.NewGuid().ToString();
            }

            if (destObj == null)
            {
                String error = "Unknown destination - " + destination + ". Make sure the destination is properly configured.";

                if (Log.isLogging(LoggingConstants.ERROR))
                {
                    Log.log(LoggingConstants.ERROR, error);
                }

                return(new ErrMessage(messageId, new Exception(error)));
            }

            Object[] bodyParts = (Object[])this.body.body;

            if (bodyParts != null && bodyParts.Length > 0)
            {
                for (int i = 0; i < bodyParts.Length; i++)
                {
                    if (bodyParts[i] is IAdaptingType)
                    {
                        bodyParts[i] = ((IAdaptingType)bodyParts[i]).defaultAdapt();
                    }
                    else if (bodyParts[i].GetType().IsArray)
                    {
                        Object[] arrayPart = (Object[])bodyParts[i];

                        for (int j = 0; j < arrayPart.Length; j++)
                        {
                            if (arrayPart[j] is IAdaptingType)
                            {
                                arrayPart[j] = ((IAdaptingType)arrayPart[j]).defaultAdapt();
                            }
                        }
                    }
                }
                destObj.messagePublished(woId, bodyParts[0]);
                destObj.GetServiceHandler().AddMessage((Hashtable)this.headers, this);
            }

            return(new AckMessage(messageId, clientId, null, new Hashtable()));
        }