Close

BizTalk Unconstructed Message Exception

Sometimes you want to create a message in BizTalk, but you can’t use a BizTalk map. An alternative for using the Transform shape, is the Assign Message shape. But, what if you can’t set the message equal to the message received via the Receive shape? You might run into an unconstructed message exception. The solution is to create an XmlDocument variable, load it up with an empty message and then set the value of the fields.

Example:

varCursusVrijVeldReq.LoadXml(“<ns0:getCursusVrijVeld xmlns:ns0=’http://osiris/services/OsirisService.wsdl’><pCursus></pCursus><pCollegejaar></pCollegejaar><pRubriek></pRubriek><pVrijVeld></pVrijVeld></ns0:getCursusVrijVeld>”);
msgOsirisCursusVrijVeldReq.getCursusVrijVeld = varCursusVrijVeldReq;

msgOsirisCursusVrijVeldReq.getCursusVrijVeld.pCursus = varCursus;
msgOsirisCursusVrijVeldReq.getCursusVrijVeld.pCollegejaar = varCollegeJaar;
msgOsirisCursusVrijVeldReq.getCursusVrijVeld.pVrijVeld = “Verwante_cursuscode”;
msgOsirisCursusVrijVeldReq.getCursusVrijVeld.pRubriek = System.Configuration.ConfigurationManager.AppSettings.Get(“OsirisElo_Verwante_cursuscode_Rubriek”);

As a sidenote, this is an example of how you can output message content to DebugView:
varXmlDoc = msgOsirisSetCursusVrijVeldResp.setCursusVrijVeldResponse;
System.Diagnostics.Debug.WriteLine(varXmlDoc.OuterXml);