none
Biztalk Schedule Adapter - Calling a .NET Class RRS feed

  • Question

  • Hi,

    Today I explored some stuff around BizTalk scheduled task adapter to use in one of my application. This adapter basically pushes 3 types of messages to message box so that an orchestration picks them. But I don't want to initiate an orchestration once the triggers fires in the adapter.

    Is it possible to call the .NET class directly from this adapter? I have an idea of calling this .NET class in a pipeline component. But want to execute a class directly from the adapter.

    Thanks


    Janardhan Reddy Bikka

    Tuesday, April 2, 2013 11:30 PM

Answers

  • HI

    You can write Custom Provider for calling .net Class , in the same way as code is written

    using System;
    using System.ComponentModel;
    using System.IO;
    using System.Xml;
    
    namespace ScheduledTaskAdapter.TaskComponents
    {
    	[Serializable()]
    	public class XmlStringArguments
    	{
    		private string xmlstring = string.Empty;
    
    		[Description("The Xml that will be returned by this scheduled task"),
            EditorAttribute("ScheduledTaskAdapter.Admin.XmlTextUITypeEditor, ScheduledTaskAdapter.Admin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=aa9f2dd0f13442dc", typeof(System.Drawing.Design.UITypeEditor)),
                TypeConverterAttribute("ScheduledTaskAdapter.Admin.XmlTextConverter, ScheduledTaskAdapter.Admin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=aa9f2dd0f13442dc")]
    		public string XmlString
    		{
    			get{return xmlstring;}
    			set {xmlstring = value;}
    		}
    	}
    	/// <summary>
    	/// XmlStringStreamProvider: implements the IScheduledTaskStreamProvider interface.
    	/// returns the configured Xml String to the  ScheduledTask Adapter as a stream
    	/// </summary>
    	public class XmlStringStreamProvider: IScheduledTaskStreamProvider
    	{
    		Stream baseStream;
    
    		public XmlStringStreamProvider()
    		{}
    
    		public Stream GetStream(object parameter)
    		{
    			XmlStringArguments args = (XmlStringArguments)parameter;
    			if (args.XmlString == string.Empty)
    					throw (new ArgumentException("XmlStreamProvider requires Xml string", "filename"));
    
    			XmlDocument document = new XmlDocument();
    			document.LoadXml((string)args.XmlString);
    			baseStream = new MemoryStream();
    			XmlTextWriter tw = new XmlTextWriter(baseStream, System.Text.Encoding.UTF8);
    			document.WriteTo(tw);
    			tw.Flush();
    			baseStream.Seek(0, SeekOrigin.Begin);
    			return baseStream;
    		}
    
    		public System.Type GetParameterType()
    		{
    			return typeof(XmlStringArguments);
    		}
    
         
        }
    }
    

    Regards

    Mohit Gupta

    Wednesday, April 3, 2013 10:53 AM

All replies

  • You can do that, but not recommend. 

    http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/ac2158e3-8a26-4e89-ada8-fb9a283f9a3c 

     

    Molly,
    Please Mark as the Answer, if this answers your question. Please vote as helpful, if this post is helpful.

    Wednesday, April 3, 2013 2:48 AM
  • Hi Bryant,

    The URL that you provided  above basically talks about calling a .net class from a pipeline VS creating a own adapter. In my case i don't want to create a custom pipeline and also adapter. Because we have the scheduled adapter already with us and in the tasks properties of this adapter we select one of 4 different default types. Instead of this is it possible to call a .NET class from here directly?

    Thanks


    Janardhan Reddy Bikka

    Wednesday, April 3, 2013 3:16 AM
  • HI

    You can write Custom Provider for calling .net Class , in the same way as code is written

    using System;
    using System.ComponentModel;
    using System.IO;
    using System.Xml;
    
    namespace ScheduledTaskAdapter.TaskComponents
    {
    	[Serializable()]
    	public class XmlStringArguments
    	{
    		private string xmlstring = string.Empty;
    
    		[Description("The Xml that will be returned by this scheduled task"),
            EditorAttribute("ScheduledTaskAdapter.Admin.XmlTextUITypeEditor, ScheduledTaskAdapter.Admin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=aa9f2dd0f13442dc", typeof(System.Drawing.Design.UITypeEditor)),
                TypeConverterAttribute("ScheduledTaskAdapter.Admin.XmlTextConverter, ScheduledTaskAdapter.Admin, Version=3.0.0.0, Culture=neutral, PublicKeyToken=aa9f2dd0f13442dc")]
    		public string XmlString
    		{
    			get{return xmlstring;}
    			set {xmlstring = value;}
    		}
    	}
    	/// <summary>
    	/// XmlStringStreamProvider: implements the IScheduledTaskStreamProvider interface.
    	/// returns the configured Xml String to the  ScheduledTask Adapter as a stream
    	/// </summary>
    	public class XmlStringStreamProvider: IScheduledTaskStreamProvider
    	{
    		Stream baseStream;
    
    		public XmlStringStreamProvider()
    		{}
    
    		public Stream GetStream(object parameter)
    		{
    			XmlStringArguments args = (XmlStringArguments)parameter;
    			if (args.XmlString == string.Empty)
    					throw (new ArgumentException("XmlStreamProvider requires Xml string", "filename"));
    
    			XmlDocument document = new XmlDocument();
    			document.LoadXml((string)args.XmlString);
    			baseStream = new MemoryStream();
    			XmlTextWriter tw = new XmlTextWriter(baseStream, System.Text.Encoding.UTF8);
    			document.WriteTo(tw);
    			tw.Flush();
    			baseStream.Seek(0, SeekOrigin.Begin);
    			return baseStream;
    		}
    
    		public System.Type GetParameterType()
    		{
    			return typeof(XmlStringArguments);
    		}
    
         
        }
    }
    

    Regards

    Mohit Gupta

    Wednesday, April 3, 2013 10:53 AM