BizTalk Server Orchestration - Creating an FlatFile Document in an Orchestration programmatically

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > May 2006 > Creating an FlatFile Document in an Orchestration programmatically





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Creating an FlatFile Document in an Orchestration programmatically
Pieter Bart van Straalen

2006-05-22, 7:14 pm

Hi,

I have created an Orchestration that does some processing. It stores the
result of these processes in a variable. This variable is declared in the
orchestration of type string. Now i want to assign the content of this
varaible to a document of type flatfile and this is were i get stuck.

My orchestration has the following flow and my problem is with expression
box 2.

1. Expression Box : CreateFFDocument
FFDocument = "SENDER:" + Message_IN.Routing.CompanyID + "'" +
Message_IN.DocumentData ;
tMapType = System.Type.GetType("TestProject.Map1,
TestProject, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=05857a55a5bdf5c1");

2. Expression Box : ConstructFFDocument <---- Problem here
construct FFMessageOut
{
FFMessageOut = FFDocument //Gives error : Cannot implicitly convert
System.String to FFMessageSchema
}
========================================
======================
second option for expression Box ConstructFFDocument
construct FFMessageOut
{
xpath(FFMessageOut ,"/*[local-name()='DocumentRoot'and
namespace-uri()='']") = FFDocument ;
}

When i now build the project i get the following errors:
1.'FFMessageOut ' is initialized but its value is never used
2.'FFMessageOut ': message has not been initialized in construct statement
3.use of unconstructed message 'FFMessageOut ' <-- When i double click this
error it opens ExpressionBox Map

If have to somehow initialize the message, if i add the statement
FFMessageOut = null;
everything compiles and deploys but then i get the following error in the
evenlog:
The part 'part' of message 'Message_1' contained a null value at the end of
the construct block.
Exception type: NullPartException

3.Expression Box : Map
construct XMLOut_Msg
{
transform (XMLOut_Msg) = tMapType(FFMessageOut);
}

I hope someone can point me in the right direction.

Regards,
Pieter.


Greg Forsythe

2006-05-23, 1:15 pm

If you are using typed message within an orchestration, they are not flat
files.
The flat file schema you have designed enables the Flat File Disassembler to
parse a flat file into an Xml message and the Flat File Assembler will
serialize the Xml message into a Flat file. While it is inside the
orchestration the message is Xml.
To create your message you can make the two fields companyId and data,
distinguished fields in your schema and use logic like this in a
MessageAssignment shape

xmlDocument.LoadXml("<root><sender>SENDER</sender><companyId/><data/></root>");
FFDocument = xmlDocument;
FFDocument.companyId = Message_IN.Routing.CompanyID;
FFDocument.data = Message_IN.DocumentData;

The xml string needs to match the schema you have defined - use Generate
Instance on the schema to get an example.

Greg




"Pieter Bart van Straalen" <pbstraalen@schouw.org[Remove]> wrote in message
news:esaHiWdfGHA.1204@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> I have created an Orchestration that does some processing. It stores the
> result of these processes in a variable. This variable is declared in the
> orchestration of type string. Now i want to assign the content of this
> varaible to a document of type flatfile and this is were i get stuck.
>
> My orchestration has the following flow and my problem is with expression
> box 2.
>
> 1. Expression Box : CreateFFDocument
> FFDocument = "SENDER:" + Message_IN.Routing.CompanyID + "'" +
> Message_IN.DocumentData ;
> tMapType = System.Type.GetType("TestProject.Map1,
> TestProject, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=05857a55a5bdf5c1");
>
> 2. Expression Box : ConstructFFDocument <---- Problem here
> construct FFMessageOut
> {
> FFMessageOut = FFDocument //Gives error : Cannot implicitly convert
> System.String to FFMessageSchema
> }
> ========================================
======================
> second option for expression Box ConstructFFDocument
> construct FFMessageOut
> {
> xpath(FFMessageOut ,"/*[local-name()='DocumentRoot'and
> namespace-uri()='']") = FFDocument ;
> }
>
> When i now build the project i get the following errors:
> 1.'FFMessageOut ' is initialized but its value is never used
> 2.'FFMessageOut ': message has not been initialized in construct statement
> 3.use of unconstructed message 'FFMessageOut ' <-- When i double click
> this error it opens ExpressionBox Map
>
> If have to somehow initialize the message, if i add the statement
> FFMessageOut = null;
> everything compiles and deploys but then i get the following error in the
> evenlog:
> The part 'part' of message 'Message_1' contained a null value at the end
> of the construct block.
> Exception type: NullPartException
>
> 3.Expression Box : Map
> construct XMLOut_Msg
> {
> transform (XMLOut_Msg) = tMapType(FFMessageOut);
> }
>
> I hope someone can point me in the right direction.
>
> Regards,
> Pieter.
>



Pieter Bart van Straalen

2006-05-29, 5:21 pm

Thanks for your reaction,

Ok, so all documents are xml in biztalk, even flatfiles.
But creating the new message the way you describe is not possible because
the message is to big and complex.

When i'm working in VS i can select a schema from the solution explorer and
do "Validate Instance". Biztalk creates the xml flatfile structure for me. I
want to do this from within an orchestration.

So in my orchestration i want to do the following:
1. Create the new document and put it in a string var.
2. Parse string var to biztalk xml
3.Create new message --> xmlDocument.LoadXml (Parsed String)

Can this be done?

Regards,
Pieter.

"Greg Forsythe" <greg.forsythe@gmail.com> wrote in message
news:uUHXWnmfGHA.2032@TK2MSFTNGP02.phx.gbl...
> If you are using typed message within an orchestration, they are not flat
> files.
> The flat file schema you have designed enables the Flat File Disassembler
> to parse a flat file into an Xml message and the Flat File Assembler will
> serialize the Xml message into a Flat file. While it is inside the
> orchestration the message is Xml.
> To create your message you can make the two fields companyId and data,
> distinguished fields in your schema and use logic like this in a
> MessageAssignment shape
>
> xmlDocument.LoadXml("<root><sender>SENDER</sender><companyId/><data/></root>");
> FFDocument = xmlDocument;
> FFDocument.companyId = Message_IN.Routing.CompanyID;
> FFDocument.data = Message_IN.DocumentData;
>
> The xml string needs to match the schema you have defined - use Generate
> Instance on the schema to get an example.
>
> Greg
>
>
>
>
> "Pieter Bart van Straalen" <pbstraalen@schouw.org[Remove]> wrote in
> message news:esaHiWdfGHA.1204@TK2MSFTNGP02.phx.gbl...
>
>



Greg Forsythe

2006-05-30, 7:15 am

Pieter,

All typed documents are Xml in Biztalk.
The use of transforms, promoted properties and distinguished fields are only
possible with Xml data.

The "Validate Instance" command will take a flat file, disassemble it into
Xml and compare with the schema.
The "Generate Instance" will produce an example flat file or Xml. If you
chose flat file then an Xml file is created and "assembled" into the flat
file output.

The standard way of handling flat files is to disassemble into Xml in a
pipeline, perform necessary processing and then assemble into a flat file in
the send pipeline.
Creating a string and then disassembling into Xml in the orchestration is
redundant, you might as well create the Xml and save yourself a step.

Automatically creating a sample instance is fine in a design time situation,
doing this in the runtime is very difficult. There are too many variables.
Do you include optional fields?, What about dates. what date do you use,
numbers are the same. If a element has a data type on xs:int then it must
contain a valid integer if the node exists. It would be very difficult to
create a single method that would suit everybody.

One way you can create this message is to use C#. You can create .Net class
based on your schema (xsd.exe), in a class library create an instance,
populate with data and serialize into Xml. This class can be compiled,
GAC'ed and called from your orchestration.
e.g.
static public System.Xml.XmlDocument MyNamespace.CreateMessage()

from an orchestration:
FFDocument = MyNamespace.CreateMessage();


Greg


"Pieter Bart van Straalen" <pbstraalen@schouw.org[Remove]> wrote in message
news:eyqUP7xgGHA.1208@TK2MSFTNGP02.phx.gbl...
> Thanks for your reaction,
>
> Ok, so all documents are xml in biztalk, even flatfiles.
> But creating the new message the way you describe is not possible because
> the message is to big and complex.
>
> When i'm working in VS i can select a schema from the solution explorer
> and do "Validate Instance". Biztalk creates the xml flatfile structure for
> me. I want to do this from within an orchestration.
>
> So in my orchestration i want to do the following:
> 1. Create the new document and put it in a string var.
> 2. Parse string var to biztalk xml
> 3.Create new message --> xmlDocument.LoadXml (Parsed String)
>
> Can this be done?
>
> Regards,
> Pieter.
>
> "Greg Forsythe" <greg.forsythe@gmail.com> wrote in message
> news:uUHXWnmfGHA.2032@TK2MSFTNGP02.phx.gbl...
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com