Click here to Skip to main content
15,897,704 members
Articles / DevOps / Load Testing

VirtualService for ESB

Rate me:
Please Sign up or sign in to vote.
4.90/5 (32 votes)
19 Feb 2008CPOL37 min read 97.1K   1.2K   98  
This article describes the design, implementation, and usage of VirtualService for the Enterprise Service Bus, using the Microsoft .NET FX 3.5 technology.
//*****************************************************************************
//    Description.....WS-Transfer Activity
//                                
//    Author..........Roman Kiss, rkiss@pathcom.com
//    Copyright © 2007 ATZ Consulting Inc. (see included license.rtf file)        
//                        
//    Date Created:    07/12/07
//
//    Date        Modified By     Description
//-----------------------------------------------------------------------------
//    07/12/07    Roman Kiss     Initial Revision
//*****************************************************************************
//
#region Namespaces
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections.Generic;
using System.Collections;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
//
using RKiss.ESB;
using RKiss.WSTransfer;
#endregion

namespace RKiss.WSTransferActivity
{
    [ToolboxItem(typeof(ActivityToolboxItem))]
    [Designer(typeof(WSRTActivityDesigner), typeof(IDesigner))]
    public partial class WSRT_Get : SequenceActivity
    {
        public WSRT_Get()
        {
            InitializeComponent();
        }

        protected override void InitializeProperties()
        {
            base.InitializeProperties();
            ResourceDescriptor = new ResourceDescriptor();
            Results = new List<Result>();
        }

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            // pre-processing
            if (GetRequest == null)
            {
                GetRequest = RKiss.WSTransfer.GetRequest.Create(MessageRequest);
            }

            // request validation
            if (GetRequest.IsResourceTransfer)
            {
                GetRequest.Validate(this.SupportedDialects);
                GetRequest.Validate(this.ExpressionsLimit);
            }
     
            // pre-processing
            int index = OperationContext.Current.IncomingMessageHeaders.FindHeader(ResourceDescriptor.DataContractName, ResourceDescriptor.DataContractNamespace);
            if (index >= 0)
            {
                ResourceDescriptor = OperationContext.Current.IncomingMessageHeaders.GetHeader<ResourceDescriptor>(index); //ResourceDescriptor.DataContractName, ResourceDescriptor.DataContractNamespace);
            }

            // for testing purposes================================
            Results.Add(new Result("123455555555555"));
            Results.Add(new Result(Guid.NewGuid()));

            // processing
            ActivityExecutionStatus status = base.Execute(executionContext);

            // post-processing
            GetResult result = new GetResult(Results);
            GetResponse = new GetResponse(GetRequest.IsResourceTransfer);
            GetResponse.Resource = GetRequest.IsResourceTransfer ? result : result.Results[0].Value;
            if (MessageRequest != null)
            {
                MessageResponse = GetResponse.CreateMessage();
            }
            
            // done
            return status;
        }

        #region Properties
        public static DependencyProperty MessageRequestProperty = DependencyProperty.Register("MessageRequest", typeof(Message), typeof(WSRT_Get));

        [DescriptionAttribute("UnTyped Message Request")]
        [CategoryAttribute("Message")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public Message MessageRequest
        {
            get
            {
                return ((Message)(base.GetValue(WSRT_Get.MessageRequestProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.MessageRequestProperty, value);
            }
        }

        public static DependencyProperty MessageResponseProperty = DependencyProperty.Register("MessageResponse", typeof(Message), typeof(WSRT_Get));

        [DescriptionAttribute("UnTyped Message Response")]
        [CategoryAttribute("Message")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public Message MessageResponse
        {
            get
            {
                return ((Message)(base.GetValue(WSRT_Get.MessageResponseProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.MessageResponseProperty, value);
            }
        }

        public static DependencyProperty GetRequestProperty = DependencyProperty.Register("GetRequest", typeof(GetRequest), typeof(WSRT_Get));

        [DescriptionAttribute("GetRequest")]
        [CategoryAttribute("Message")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public GetRequest GetRequest
        {
            get
            {
                return ((GetRequest)(base.GetValue(WSRT_Get.GetRequestProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.GetRequestProperty, value);
            }
        }

        public static DependencyProperty GetResponseProperty = DependencyProperty.Register("GetResponse", typeof(GetResponse), typeof(WSRT_Get));

        [DescriptionAttribute("GetResponse")]
        [CategoryAttribute("Message")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public GetResponse GetResponse
        {
            get
            {
                return ((GetResponse)(base.GetValue(WSRT_Get.GetResponseProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.GetResponseProperty, value);
            }
        }

        public static DependencyProperty ResourceDescriptorProperty = DependencyProperty.Register("ResourceDescriptor", typeof(ResourceDescriptor), typeof(WSRT_Get));

        [DescriptionAttribute("ResourceDescriptor")]
        [CategoryAttribute("Resource")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public ResourceDescriptor ResourceDescriptor
        {
            get
            {
                return ((ResourceDescriptor)(base.GetValue(WSRT_Get.ResourceDescriptorProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.ResourceDescriptorProperty, value);
            }
        }

        public static DependencyProperty ResultsProperty = DependencyProperty.Register("Results", typeof(List<Result>), typeof(WSRT_Get));

        [DescriptionAttribute("List of the Results (Resources)")]
        [CategoryAttribute("Resource")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public List<Result> Results
        {
            get
            {
                return ((List<Result>)(base.GetValue(WSRT_Get.ResultsProperty)));
            }
            set
            {
                base.SetValue(WSRT_Get.ResultsProperty, value);
            }
        }


        public List<string> SupportedDialects { get; set; }
        public uint ExpressionsLimit{ get; set; }
       

        #endregion
    }




 
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions