locked
Message construction with message shape. RRS feed

  • Question

  • I would like to construct a message lets say myMsg in Assignment shape. I do not want to use LoadXml() , also not through class library, even not through dump map. How can I do it? After that I would like to assign some value to a property of myMsg .

    myMsg.ABC = "My string";

    How can I do it


    Hello

    Thursday, July 11, 2013 6:21 AM

Answers

  • Well, you've pretty much ruled out the easiest, and probably most common, ways of creating an instance of XmlDocument, which you have to do.  My preference is a Map, by the way.

    Is there a reason for this restriction?

    What you're describing, I do all the time.  Use a map with the new Message as the destination, the source doesn't really matter.  Set a default Value on the fields.  Then in an Message Assignment, set you field's value by the Distinguished Field.

    There's no performance issues and really no other 'correct way'.

    • Marked as answer by Pabitra Dash Thursday, July 11, 2013 2:26 PM
    Thursday, July 11, 2013 12:37 PM
    Moderator

All replies

  • Pabitra,

    You can't, you'll have to use on of the methods you say you do not want to use.

    Regards,

    René

    Thursday, July 11, 2013 8:24 AM
  • Hi Prabitra,

    Before you can assign a value to the distinguished filed of a message you have to initialize the message.  A message can be constructed by one of the following standard ways in orchestration:

    • Using a map
    • Assing message to another
    • Create message with XMLDocuent variable
    • Use a .Net helper class to create the message.
    • Creating a more complex message using : System.XML.Document, System.XML.XMLNode,System.XML. XMLAttribute, Interim BizTalk Message
    • Use a .Net helper class to create the message

    Referr this article for the sample code for these methods : http://blogs.objectsharp.com/post/2004/11/09/Constructing-BizTalk-2004-XML-Messages-(In-an-Orchestration)-Choices.aspx

    Any reason why you don’t want to use these methods.

    Michael Stephenson and Darren Jefford had blogged another method but they still use external NET Assembly from Orchestration with Schema Types.

    http://geekswithblogs.net/michaelstephenson/archive/2006/09/26/92363.aspx

    http://blogs.msdn.com/b/darrenj/archive/2004/09/29/235719.aspx


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.


    Thursday, July 11, 2013 8:58 AM
  • Well, you've pretty much ruled out the easiest, and probably most common, ways of creating an instance of XmlDocument, which you have to do.  My preference is a Map, by the way.

    Is there a reason for this restriction?

    What you're describing, I do all the time.  Use a map with the new Message as the destination, the source doesn't really matter.  Set a default Value on the fields.  Then in an Message Assignment, set you field's value by the Distinguished Field.

    There's no performance issues and really no other 'correct way'.

    • Marked as answer by Pabitra Dash Thursday, July 11, 2013 2:26 PM
    Thursday, July 11, 2013 12:37 PM
    Moderator
  • use the third way.

    Use the message schema and through "xsd.exe" generate a class. Use a helper function to create an instance of the the class and return to Orchestration through the function. In the orchestration declare a variable of the same class type. Assign this return from the helper class to the orchestration variable or to the message instance (BizTalk takes care of the de-serialization).

    Use the message with a distinguished property to execute the second step.

    Regards.


    • Edited by Shankycheil Thursday, July 11, 2013 1:10 PM variable declaration in orchetsration
    Thursday, July 11, 2013 12:53 PM
  • Thanks for your response. I was trying the way you suggested. But for now I postponed that, used LoadXml(). Thank you all for your response.

    Hello

    Thursday, July 11, 2013 2:26 PM
  • >>> Use a map with the new Message as the destination, the source doesn't really matter.

    I tried with a map as you say, but I get a compilation error 'source' is unreconstructed.

    I tried to assign the result of 'Get Application Value' functoid to one field of destination message. I do not care source. In my map I set both source and destination same. But it says me 'source' is unreconstructed. Can I do it with assignment construct instead of Map?


    Hello

    Monday, July 29, 2013 7:57 AM
  • Pabitra,

    You cannot use Get Application Value outside a map.

    What you can do is use your incoming message (the one received in the activating receive of your orchestration) as a source for the map.

    Regards,

    René

    Monday, July 29, 2013 8:04 AM
  • I am using this Map in a 'called Orchestartion', which does not accept parameter from calling Orchestartion. So I do not have any incoming message here.

    Hello

    Monday, July 29, 2013 8:38 AM
  • Then use an Assignment to setup a dummy destination message, i.e.

    xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml("<any/>");
    [DestinationMsg] = xmlDoc;

    Regards,

    René

    Monday, July 29, 2013 8:51 AM

  • There are several ways to construct message

    • Using a map
    • Assing message to another
    • Create message with XMLDocuent variable
    • Use a .Net helper class to create the message.
    • Creating a more complex message using : System.XML.Document, System.XML.XMLNode,System.XML. XMLAttribute, Interim BizTalk Messaging
    • Use a .Net helper class to create the message

    But in my opinion use a map with the new Message as the destination, the source doesn't really matter. 

    There is also an alternate option which will provide an easy way to build messages and also save time in troubleshooting

    http://www.athenainfotech.co.uk/managed-b2b-services

    Monday, July 29, 2013 8:58 AM
  • Hi Rene,

    Thanks. But sorry I could not understand here. Where I would assign the result of 'Get Application Value' functoid to destimation message.

    Is the flow would be as follows?

    1) First use an Assignment to setup a dummy destination message, say MsgDest.

    2) Then use the map as I described above, where source and destination messages are MsgDest?

    Regards,

    Pabitra


    Hello

    Monday, July 29, 2013 9:04 AM
  • Thanks. Which one of above fit to my scenario?

    Hello

    Monday, July 29, 2013 9:05 AM
  • Pabitra,

    yes, because you use the destination message both as source as destination of your map, you get the use of unconstructed message, so if you first create a dummy message of the destination message, you won't get that error anymore.

    Monday, July 29, 2013 9:27 AM
  • Hi Rene,

    I got following error. It says 'Root Element is missing'.

    The adapter failed to transmit message going to send port "BrontoIntSoapApiImplPort" with URL "https://api.bronto.com/v4". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.Xml.XmlException: Root element is missing.
       at System.Xml.XmlTextReaderImpl.Throw(Exception e)
       at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
       at System.Xml.XmlTextReaderImpl.Read()
       at System.Xml.XmlReader.MoveToContent()
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkBodyWriter.ValidateStreamContainsXml(Stream stream)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkBodyWriter..ctor(Stream stream, BodyReadCallback callback, Object state, Boolean validateStreamIsXml)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfMarshaller.CreateWcfMessage(CreateWcfMessageSettings settings, TLConfig tlConfig, RLConfig rlConfig)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendRequestMessage(IBaseMessage bizTalkMessage, IRequestChannel channel)
       at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.SendMessage(IBaseMessage bizTalkMessage)".


    Hello

    Monday, July 29, 2013 11:41 AM
  • How does your map look like?
    Monday, July 29, 2013 11:46 AM
  • In Map, source and destination message of type Bronto.LogIn and a string is retrieved through 'Get Application Value' functoid and assigned to destination message LogIn.AppKey field.

    Hello

    Monday, July 29, 2013 11:55 AM
  • Did you test the map in Visual Studio?

    And did it produce the expected output?

    Monday, July 29, 2013 12:02 PM
  • No, i do not. Now I reverted back to previous version. But I would do it and get back to you.

    Hello

    Monday, July 29, 2013 12:05 PM
  • 1. Any message will do, such as the Activating message or any other already Constructed Message.  The Source and Destination Message cannot be the same because it hasn't been Constructed yet.

    2. You can connect the Get App Value directly to the appropriate destination node.  You will though have to hard code the parameters.

    Monday, July 29, 2013 1:53 PM
    Moderator
  • Hi Rene,

    The maps looks like following.

    To construct the message 'BrontoApiToken' I use message assignment first with following code

    xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml("<any/>");
    BrontoApiToken = xmlDoc;

    then followed followed by a map, which is displayed below. Here both source and destination schema are same.

    It Use 'Get Application Value' function to get the api token key.

    Now when I would like to print 'apiToken' after above construct in event log with following code it does not print anything.

    System.Diagnostics.EventLog.WriteEntry("apikey", BrontoApiToken.apiToken);

    However when I test map in visual studio I get following xml, which is fine.

    - <ns0:Token xmlns:ns0="http://BCI_DataSync.com/schemas/DataSync/internal/2013-06">
      <apiToken>1234</apiToken>
    </ns0:Token>

    But no idea why it does not print apiToken in event log. Do you have any idea on this. Please help.


    Hello

    Wednesday, August 7, 2013 6:12 AM
  • I constructed source message with following code.

    xmlDoc = new System.Xml.XmlDocument();
    xmlDoc.LoadXml("<any/>");
    BrontoApiToken = xmlDoc;

    I do not get any compilation error when source and destination message are same.


    Hello

    Wednesday, August 7, 2013 6:23 AM
  • Hello,

    Can somebody help me to resolve above problem? In above map there is no incoming message to this Orchestration as it is called from other Orchestration.

    can I have a dummy message construct first with empty XML element, then this message would be source message to mapper.

    Please help.

    Regards,

    Pabitra


    Hello

    Friday, August 9, 2013 5:30 PM
  • with so much of programming already in place I see no reason for you to insist on mapping... anyways..just my opinion.

    In your orchestration, you'd need a message construct shape and construct TWO (MessageOne & MessageTwo) Messages. MessageOne = your dummy message ( which you're creating using the XmlDocument with "<any />" as the content).

    In the same "Message Construct" shape add a "Transform" shape which will use "MessageOne" and then Map to "MessageTwo" using the map.

    Regards.

    Saturday, August 10, 2013 6:45 AM