开发者

Call a Method that have object parameters from a BizTalk scripting functoid

I need to call a method in an external assembly from a scripting functoid in a BizTalk map, in particular a Enumerated type is 开发者_如何学运维a parameter in a C# assembly. Is this even possible? I have passed in strings or integers while calling external assemblies many times with no problems.


Unfortunately, you cannot use enumerated types in methods designed to be called from the scripting functoid. However, you can nearly achieve what you want by creating a wrapper around the external method.

For instance, the following method cannot be called directly from a scripting functoid.

using System;

namespace ExternalAssembly
{
    public enum Options
    {
        OptionNumberOne,
        OptionNumberTwo,
    }

    public class Helper
    {
        public string DoSomething(Options option)
        {
            // really do something useful here
            return String.Empty;
        }
    }
}

Attempting to use this method will result in the following error:

Function 'ScriptNS0:DoSomething()' has failed. Value was either too large or too small for an Int32.

However, if you write the following wrapper method, if works:

    public string DoSomething(string option)
    {
        return Helper.DoSomething(
              (Options) Enum.Parse(typeof(Options), option)
            );
    }

Notice that the wrapper method is using a regular String parameter, instead of the original Options enumerated type. If you have the source code for the method you want to call, just add this extra wrapper as and overload and you're done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜