Messages and variables : Use of unconstructed Message


Many of us would have faced Use of unconstucted Message Error in the Construct Message shape.


Our need would have been to only intialize it with empty constructor. But it would force us to create a message by


1. Loading and empty xml instance of the xsd schema type.


2. Use a Biztalk mapper to transform from a different message.


Simpler way is to use:


a. Xsd.exe to convert the schema to a .cs file.


b. Add the .cs to file to a csharp class library project.


c. Add reference from the bts project to the class library


d. Create a variable of the csharp datatype created by xsd.


e.In the construct shape Assign Msgx = Variablex, this will initialize the variable with the default values and it is error free.


OverHeads:


You need to regenerate the .cs file using xsd.exe whenever the schema changes .


 

Comments (3)
  1. Dourn says:

    Hi there – it’s worth noting that this won’t always work for complex schemas e.g. using Base Types and Inheritance in a schema (xsi:type=”something”).

    The reason for this is due to the fact that the XSD.exe tool can only create an accurate class representation of a schema for certain (usually simple) schemas.

    So it’s possible to end up with a scenario where the serialised class you’ve ended up with won’t validate against the original schema – but unless you do something that validates your message you won’t necessarily know this (by default, BizTalk doesn’t validate your messages against schemas inside of an orchestration).

    Therefore you could end up with a situation where you return a message from an orchestration which isn’t valid.

    Cheers,

    Daniel Probert

    http://www.bizbert.com

  2. Y2KPRABU says:

    yes this is possible only if the xsd tool is able to generate an accurate class.

Comments are closed.

Skip to main content