Message construction with message shape.

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

July 11th, 2013 2:23am

Pabitra,

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

Regards,

Ren

Free Windows Admin Tool Kit Click here and download it now
July 11th, 2013 4:26am

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 dont 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.as

July 11th, 2013 5:00am

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'.

Free Windows Admin Tool Kit Click here and download it now
July 11th, 2013 8:39am

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.


July 11th, 2013 8:56am

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.
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2013 10:28am

>>> 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?

July 29th, 2013 4:00am

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

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 4:07am

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.
July 29th, 2013 4:41am

Then use an Assignment to setup a dummy destination message, i.e.

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

Regards,

Ren

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 4:54am


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

July 29th, 2013 5:02am

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

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 5:07am

Thanks. Which one of above fit to my scenario?
July 29th, 2013 5:08am

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.

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 5:30am

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)".

July 29th, 2013 7:44am

How does your map look like?
Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 7:50am

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.
July 29th, 2013 7:59am

Did you test the map in Visual Studio?

And did it produce the expected output?

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 8:05am

No, i do not. Now I reverted back to previous version. But I would do it and get back to you.
July 29th, 2013 8:08am

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.

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2013 9:57am

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.

August 7th, 2013 2:18am

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.

Free Windows Admin Tool Kit Click here and download it now
August 7th, 2013 2:28am

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

August 9th, 2013 1:36pm

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.

Free Windows Admin Tool Kit Click here and download it now
August 10th, 2013 2:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics