none
Accesing a message's property... Null Reference exception RRS feed

  • Question

  • Hello there,

    I have an orchestration that deBatches an envelope message.

    To do so, I have previously received a select query from an oracle server, copied it to the envelope message and then I enter an atomic transaction to loop through the envelope message.

    Both schemas envelopeMessage and singleMessage have a distinguis filed that I need to access but when I try to do so, in any way, the orchestration raises the following exception:

    xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'TriggerBranching.OralceSelectTAR01(6fae9cbb-5f56-d15d-60d3-ac7d53265cd5)'.
    The service instance will remain suspended until administratively resumed or terminated. 
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: 45058dee-6997-406c-a29b-7887f43ef273
    Shape name: ConstructMessage_1
    ShapeId: 2793b30f-88f0-4bfa-97ad-4334bb4aaa50
    Exception thrown from: segment 2, progress 12
    Inner exception: Object reference not set to an instance of an object.
            
    Exception type: NullReferenceException
    Source: myAPP
    Target Site: Microsoft.XLANGs.Core.StopConditions segment2(Microsoft.XLANGs.Core.StopConditions)
    The following is a stack trace that identifies the location where the exception occured
    
       at myAPP.myOrchestration.segment2(StopConditions stopOn)
       at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
    


    I have tried promoting a property using a propertySchema but I am not sure I've done it right... oh and it is still not working.

    If I send the message through a send port and write it to disk, all the messages get generated in disk but if I try to send that message to another orchestration and use it from there, it also fails.

    Here's a little illustration of what I have:

    And there's the code on the expression shapes:

    [Assign Pipeline]
    System.Diagnostics.EventLog.WriteEntry("my_BTS_APP", "Starting De-Batch");
    rcvPipeline = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(Microsoft.BizTalk.DefaultPipelines.XMLReceive),msgItemsEnvelope);
    
    [Construct Message 1]
    msgSingleItem = new System.Xml.XmlDocument();
    rcvPipeline.GetCurrent(msgSingleItem);
    myDecimalProperty = msgSingleItem.DecimalProperty
    System.Diagnostics.EventLog.WriteEntry("my_BTS_APP", myDecimalProperty.ToString());
    


    Thanks in advance for any help! and do not hesitate to ask if you need more info, just tell me what would you need!

     

    Carlos

     

    Tuesday, October 4, 2011 11:25 AM

Answers

  • instead of elementName in my previoius post you you can try this, basically you can put the Instance XPath property from the elements properties in the editor as input to string() of xpath. Hope this helps. 

     

    respStatus = System.Convert.ToString(xpath(BizTalkMEssage,"string(/*[local-name()='RootNode']/*[local-name()='elementName'])"));
    
    

    and for converting a biztalk message to string you can create a XMLDocument variable and do something like the following 

    testXmlDocument = InputMsg;
    
    inputMsgStr = testXmlDocument.OuterXml;


     


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    • Edited by DPS Bali Wednesday, October 5, 2011 10:32 AM
    • Marked as answer by CarlosEd Wednesday, October 5, 2011 11:08 AM
    Wednesday, October 5, 2011 10:30 AM

All replies

  • Update:

    This is the suspended message view... it also says Part Count = 0

    The funny thing is that this only occurs if I try to use the promoted property/field of the message, if I send the message through a port it gets written to disk perfectly. This is driving me crazy! -again-

    The messages, 'Single' and 'Envelope' are defined from the schema generated from the consume adapter service via import.

     

    Thoughts are greatly appreciated, I'm running out of ideas/tries here.

     

    Carlos

     

     

    Tuesday, October 4, 2011 5:21 PM
  • Hi Carlos, 

    You can try this, however not sure if this will help fulfil your requirement. Use an inbound map on the request response port which gets the results of select query on the oracle server and then this will publish the envelop message to the message box which you can subscribe to and de-batch.


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Tuesday, October 4, 2011 7:54 PM
  • Hi Bali,

    I think I get the envelope message right, at least, if I save it as an xml file it's all there. For some reason it's the single messages what I can't seem to access and this is the crazy part, If I save them as individual xml files the output is correct, but if I try to access a promoted property... "exception"

     

    Thanks a lot man!

    Wednesday, October 5, 2011 6:53 AM
  • Hi Carlos,

    Look at this blog post , it explains the debatching of results from WCF SQL Adapter, you will have to replicate something similar to get this working for WCF Oracle Adapter. Also am not  too sure about the property promotion from the body of an envelop message. You can using XPath instead in an expression shape to get the value of the element in question.

    respStatus = System.Convert.ToString(xpath(BizTalkMEssage,"string(//elementName)"));
    
    respStatus is a Orchestration variable of type String. 


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Wednesday, October 5, 2011 8:24 AM
  • Hi Bali,

    Actually, that's the post I followed to create my schemas, because they very large and somewhat complex so I'd try to import the schema from the one generated from the consume adapter. What a problem...

    Wednesday, October 5, 2011 8:33 AM
  • Hi Bali,

    Is there a way to convert the entire message to string? If I use respStatus = System.Convert.ToString(msgSingle); I get the message type back.

    The xpath is returning blank or null, so I am fearing that I am not getting the XPath right... maybe messed up namespaces or something. It has been very very difficult to work on this ver very simple thing... *sigh*

    Wednesday, October 5, 2011 9:48 AM
  • I have typed the XPath in this instruction:

    respStatus = System.Convert.ToString(xpath(BizTalkMEssage,"string(//elementName)"));

    And I got this response:

    Microsoft.XLANGs.Core.Part+ArrayBasedXmlNodeList

     

    That one should be one element, I am confused

    Wednesday, October 5, 2011 10:18 AM
  • instead of elementName in my previoius post you you can try this, basically you can put the Instance XPath property from the elements properties in the editor as input to string() of xpath. Hope this helps. 

     

    respStatus = System.Convert.ToString(xpath(BizTalkMEssage,"string(/*[local-name()='RootNode']/*[local-name()='elementName'])"));
    
    

    and for converting a biztalk message to string you can create a XMLDocument variable and do something like the following 

    testXmlDocument = InputMsg;
    
    inputMsgStr = testXmlDocument.OuterXml;


     


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    • Edited by DPS Bali Wednesday, October 5, 2011 10:32 AM
    • Marked as answer by CarlosEd Wednesday, October 5, 2011 11:08 AM
    Wednesday, October 5, 2011 10:30 AM
  • Man, that worked...

     

    respStatus = System.Convert.ToString(xpath(BizTalkMEssage,"string(/*[local-name()='RootNode']/*[local-name()='elementName'])"));

    But why? Why I am not able to read the message? and I have to access it through XPath? if the information is obviously there.

    Just to try to understand... this is what I send and get:

    respStatus = System.Convert.ToString(xpath(msgSingle, "string(/*[local-name()='ROOTNODE']/*[local-name()='RECORD'])"));
    System.Diagnostics.EventLog.WriteEntry("BTS_APP", respStatus);
    //Response: 30211000283 (the right stuff)

    oXMLDoc = msgSingle;
    respStatus = oXMLDoc.OuterXml;
    System.Diagnostics.EventLog.WriteEntry("BTS_APP", respStatus);
    //Response:
    <ns0:ROOTNODE xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/MYPACKAGE/Table/MYTABLE"><ns0:RECORDVALUE>30211000283</ns0:RECORDVALUE></ns0:ROOTNODE>

    So, the info is there, but I can't freely access it... any thoughts on that?

    And last but not at all least, I want to thank you for your huge patience on sharing your wisdom!

    You honestly made my week!

    Carlos.

    Wednesday, October 5, 2011 11:08 AM
  • Your welcome ... :) 

    I think the issue is when you are trying to promote the property from the body of the Envelop Message it's not possible because it is repeated.

    Check this blog post to get some clarity .. 


    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    My Blog:dpsbali-biztalkweblog
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Wednesday, October 5, 2011 11:42 AM