none
How to use variable in catch exception block which is used in scope shape BizTalk Orchestration RRS feed

  • Question

  • Hi All,
    I have a general query regarding catching exception in orchestration ...
    I am receiving email using POP3 adapter and reading encrypted subject line ..and doing some update in SQL database..
    now if by chance user delete subject line which is encrypted ..then i need to send email to user...
    my question is in scope shape i am getting FROM field of email using

    OrgEmail=Message_InboundMsg(POP3.From);
    then i call function in class library..to remove '<' from email..

    FromEmail = objDecrypt.getOrgEmail(OrgEmail); ...

    So my question is how can i sue this variable in expression shape in catch exception block..
    so that i can again call function in class library to send email to user...

    Thanks..
    Sandeep

    Tuesday, June 23, 2009 7:05 AM

Answers

  • Hi,

    VarMailMsg should be of String type, it will be simple string assignment like VarMailMsg="test";

    Also one suggestion always try to minimize the use of XMLDOM (it consumes good amount of memory), so try to dispose the Object after use.
    Ajeet Kumar
    • Marked as answer by Sandeep.Handa Wednesday, June 24, 2009 9:02 AM
    Tuesday, June 23, 2009 1:32 PM

All replies

  • You can use in the same way as you are doing in here. There won't be any difference in calling, the only thing you need to take care is scope of the variable. Say you have defined a variable of UrClassLib type, so if you want to use the same instance of the class(in the exception block) then don't dispose the Object inside the scope. You can make use of the same instance of the object and call the functions you want and then can dispose the object.
    Ajeet Kumar
    Tuesday, June 23, 2009 8:34 AM
  • Hi Ajeet,
    Thanks for your reply..
    What i did is used the same expression in catch block..
    One thing i want to know is.. i a constructing a message Message_POP3 in scope block using construct shape...then after catch block i am further sending data to SQL to update some table...
    but i get error that Message_POP3 is unconstructed..if there is not exception ...
    how would i construct message again...

     

    In scope block i use the code in expression shape as 
    
    XMLDOM = new System.Xml.XmlDocument();
    
    
    XMLDOM.LoadXml(@"<ns0:Submitter xmlns:ns0=""http://schemas.microsoft.com/BizTalk/2003""><from>from_0</from><AppName>AppName_0</AppName></ns0:Submitter>"); 
    
    
    Message_POP3 = XMLDOM;
    Message_POP3.AppName = AppName;
    
    
    

     

    whether i need to use another contruct shape after catch block and again use the same code...
    Pls help..

    Sandeep



    Tuesday, June 23, 2009 10:48 AM
  • Hi,

    You would need to construct the msg again in the exception block. As i see whole message (except AppName) you are hardcoding), so can use one variable of String type to hold this value and use the same variable inside scope and in exception block.

    like varMailMsg=
    "<ns0:Submitter xmlns:ns0=""http://schemas.microsoft.com/BizTalk/2003""><from>from_0</from><AppName>AppName_0</AppName></ns0:Submitter>"
    ); 

    then use like
    XMLDOM.LoadXml(varMailMsg); at both the places

    but make sure the variable is global to that scope and also set the value before the scope.





    Ajeet Kumar
    Tuesday, June 23, 2009 11:55 AM
  • Hi Ajeet,
    I used variable before scope block in expression shape like
    XMLDOM = new System.Xml.XmlDocument();
    
     
    VarMailMsg = ("<ns0:Submitter xmlns:ns0=""http://schemas.microsoft.com/BizTalk/2003""><from>from_0</from><AppName>AppName_0</AppName</ns0:Submitter>"); 
    
      
    Its giving error  expected )
    do i need to convert " to ' ....
    Pls reply...
    Tuesday, June 23, 2009 1:17 PM
  • Hi,

    VarMailMsg should be of String type, it will be simple string assignment like VarMailMsg="test";

    Also one suggestion always try to minimize the use of XMLDOM (it consumes good amount of memory), so try to dispose the Object after use.
    Ajeet Kumar
    • Marked as answer by Sandeep.Handa Wednesday, June 24, 2009 9:02 AM
    Tuesday, June 23, 2009 1:32 PM