Accessing a static method from Orchestration Expression
-
Thursday, January 28, 2010 10:48 AMHi allHow can I access the method getXmlDocumentfrom a Orchestration ExpressionI tried something like thisvar = new %namespace%.Invoice_Decoder(); //Note Var is type %namespace.Invoice_Decoder%varGet = var.getXmlDocument(msgCoded); // varGet is type System.Xml.DocumentThe error message below is showing getXmlDocument %Error%(msgCoded) between getXmlDocument and (msgCoded)I am getting an errorstatic member cannot be accessed with an instance reference qualify it with a type name instead
[Serializable] public class Invoice_Decoder { public Invoice_Decoder() { // // TODO: Add constructor logic here // } public static XmlDocument getXmlDocument(XLANGMessage baseCodeInvMessage ) { blalba }
AKE
All Replies
-
Thursday, January 28, 2010 10:52 AMAnswererYou can not access a static method from an instance. Your code should read:
varGet = %namespace%.Invoice_Decoder.getXmlDocument(msgCoded); -
Thursday, January 28, 2010 10:59 AMModeratorHi AKE,
I assume you want to call a custom .NET component. Here is an example of an implementation, which could be usefull for you to review: http://www.codeproject.com/KB/biztalk/CallCustomDllBiztalk2006.aspx.
Regards,
Steef-Jan Wiggers (http://soa-thoughts.blogspot.com/)
BizTalk Server -
Thursday, January 28, 2010 11:03 AMHIThanks for speedy response:-)
AKE -
Thursday, January 28, 2010 2:30 PMHi allI tried all the solution above ..Non of them workedI was getting the error..must be a type : when I use: varGet = %namespace%.Invoice_Decoder.getXmlDocument(msgCoded);getXmlDocument "must be a type"As soon as I remove the static type.. it works with out problem..But I have a need to use the static.Thanks in Advance
AKE -
Thursday, January 28, 2010 2:36 PMModeratorHi AKE,
Is there a particular reason you need to use static. Maybe you could review this post: http://seroter.wordpress.com/2007/08/17/behavior-of-static-objects-in-biztalk-runtime/.
Regards,
Steef-Jan
BizTalk Server -
Thursday, January 28, 2010 2:40 PMHi JanNeed to make sure that is only 1 instance of the objectis alive during a transactionHow save is using just public XmlDocumet?Regards
AKE -
Thursday, January 28, 2010 2:43 PMModeratorHi AKE,
Well look into this post http://seroter.wordpress.com/2007/08/17/behavior-of-static-objects-in-biztalk-runtime/.. or have a look here: http://msdn.microsoft.com/en-us/library/ee377042(BTS.10).aspx.
Regards,
Steef-Jan
BizTalk Server -
Thursday, January 28, 2010 3:14 PM
Hi AKE,
As suggested by Greg, using the class name should work to call a static method of class from Orchestration expression shape.
varGet = %namespace%.Invoice_Decoder.getXmlDocument(msgCoded);
I have called static methods of external assemblies it in many projects without any issue. Are you getting error at design time or run time?
If your class is a utility class with only static methods, then change the class also to static and then you do not need to use [Serializable] for a static class. Make sure to Gac the assembly and restart host instance before testing it (you may not have restarted host insatce in your last test).
Regards,
Tariq Majeed
Please mark it as answer if it helps- Marked As Answer by Akaschmid Tuesday, February 02, 2010 6:35 AM
-
Thursday, January 28, 2010 6:38 PM
As Tariq mentioned, you just need to make sure that your latest changes are reflected ..During development, you can ensure this by writing some information messages into event log from your static method.
HTH,
Please mark it as answer by clicking on "Propose As Answer", if it helps -
Thursday, January 28, 2010 8:40 PM
If your class is a utility class with only static methods, then change the class also to static and then you do not need to use [Serializable] for a static class. Make sure to Gac the assembly and restart host instance before testing it (you may not have restarted host insatce in your last test).Hi Tariq .. I think you made a point.. here.. class with only static methods, need to be static class also..
I will try this tomorrow morning and give you the feedback
Kind regards
AKE -
Friday, January 29, 2010 9:03 AM
Hi,
The methods in a static class need to be reentrant and threadsafe, because many orchestration instances could simultainously call the same method. Hence better way is to go for a singleton class instead of a static class. When you call methods of a singleton class separate stack frame is created for each such call and hence no complications.
Please mark as answer if this helps you. Thanks and warm regards Ambar Ray EAI Architect - Microsoft Technologies -
Tuesday, February 02, 2010 6:37 AMHi allThanks for your effort..The static class solved my problem for now..Later I will have a look at the constraints as a result of calling a static method in an Orch..BestRegards
AKE

