BizTalk Server General - Dynamic Maps In Orchestrations

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > August 2005 > Dynamic Maps In Orchestrations





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 Dynamic Maps In Orchestrations
BizTalk Benjamin

2005-08-24, 6:04 pm

Hi, I think I posted about this a while ago, but didnt get it resolved.

I have a large number of Flat and XML files in different XSD's coming into
my system. I need to convert them all into a common format and have maps for
each. Additionally i have a custom schema validation component which i can
call from an orchestration.

Now I could put all the maps in a receive port and pick up the message in an
orchestration, call the validator and go from there. But if any exceptions
occur during the mapping, then i wont be able to handle them gracefully. I
would rather put the mapping into an orchestration which i could surround
with a try-catch and do some error handling.

I came across an MSDN topic titled "Assigning to Transforms Dynamically",
which seemed to touch on this issue but is difficult to understand. The
supplied code snippet is rather weird (see below). Apparently you have to put
it in a message assignment shape. I can put the if-else block in the shape,
but BizTalk doesnt recognise the construct keyword. Additionally, there is no
explanation as to what the different messages are and what the x1,x2,s1 and
s2 are.

construct _responseMessage
{
transform (responseMessage.x1, _responseMessage.x2) =
MapType(requestMessage.s1, _requestMessage.s2);
}

Has anyone used this before or have any other sample code which will let me
call maps dynamically?

Hoping someone can help

cheers
benjy


Stephen W. Thomas

2005-08-24, 8:51 pm

Hello.

I think MSDN is incorrect in this case. It needs to be inside an Expression
Shape using the Construct key word.

We took the exact same approach to solve the same problem on my last
projects. We used dynamic maps as well and it worked great. Except you need
to use the full assembly name if the maps are outside of your project.

I have some sample code. I just have to track it down. I’ll post it once I
find it.

Hope this helps.

Stephen W. Thomas
http://www.biztalkgurus.com


"BizTalk Benjamin" wrote:

> Hi, I think I posted about this a while ago, but didnt get it resolved.
>
> I have a large number of Flat and XML files in different XSD's coming into
> my system. I need to convert them all into a common format and have maps for
> each. Additionally i have a custom schema validation component which i can
> call from an orchestration.
>
> Now I could put all the maps in a receive port and pick up the message in an
> orchestration, call the validator and go from there. But if any exceptions
> occur during the mapping, then i wont be able to handle them gracefully. I
> would rather put the mapping into an orchestration which i could surround
> with a try-catch and do some error handling.
>
> I came across an MSDN topic titled "Assigning to Transforms Dynamically",
> which seemed to touch on this issue but is difficult to understand. The
> supplied code snippet is rather weird (see below). Apparently you have to put
> it in a message assignment shape. I can put the if-else block in the shape,
> but BizTalk doesnt recognise the construct keyword. Additionally, there is no
> explanation as to what the different messages are and what the x1,x2,s1 and
> s2 are.
>
> construct _responseMessage
> {
> transform (responseMessage.x1, _responseMessage.x2) =
> MapType(requestMessage.s1, _requestMessage.s2);
> }
>
> Has anyone used this before or have any other sample code which will let me
> call maps dynamically?
>
> Hoping someone can help
>
> cheers
> benjy
>
>

BizTalk Benjamin

2005-08-24, 8:51 pm

Hi Stephen,

Thanks for the reply. I have solved it (and was just going to post a
followup when i saw your reply) . There are a couple of things

(1) the documentation has copied the code that lives behind an
orchestration. I opened an odx in notepad and found the "transform" and
"construct keywords. So we need to ignore the construct keyword since that is
actually the name of the shape

(2) the correct line in the message assignment shape is
transform(Message_2) = Namespace.MapName(Message_1)
There is no need for any other parts. Maybe you would need specific part
names if you were using a multi part message

Im currently working through the dynamic mapping where the orchestration has
a member variable of type System.Type to hold the fully qualified map name.
It passes the input file name (FILE.ReceivedFileName) to a helper class which
then picks up the typename of the correct map and returns it to the orch
which loads it up and does the mapping.

I got it working for one message (it maps Message_A to Message_Common) but
there are some bugs somewhere and for the second transformation (Message_B to
Message_Common) it returns an empty result. I checked the maps and they are
fine by themselves (test/validate).

Im trying to get the helper class to log its results to a text file so i can
trace the issue. Strangely, it refuses to write any text files (and doesnt
throw any exceptions either). Its kinda weird cos I managed to get EntLib
logging working for my main project so a simple file write should be a piece
of cake. Anyway, thats deviating from the point and only serves to illustrate
that we cant take anything for granted in BTS.

Its well past midnight so i gotta go get some sleep.

If you could share some of your code, that would be great. It could help me
sort out my algorithm too.

Cheers
Benjy

"Stephen W. Thomas" wrote:
[vbcol=seagreen]
> Hello.
>
> I think MSDN is incorrect in this case. It needs to be inside an Expression
> Shape using the Construct key word.
>
> We took the exact same approach to solve the same problem on my last
> projects. We used dynamic maps as well and it worked great. Except you need
> to use the full assembly name if the maps are outside of your project.
>
> I have some sample code. I just have to track it down. I’ll post it once I
> find it.
>
> Hope this helps.
>
> Stephen W. Thomas
> http://www.biztalkgurus.com
>
>
> "BizTalk Benjamin" wrote:
>
Stephen W. Thomas

2005-08-25, 6:02 pm

Hello.

I got some sample code posted here:
http://www.biztalkgurus.com/Samples...hestration.html

I’ll do a better write up a little later today.

If I remember correctly, we got an empty result a lot. In fact, I had to
check for that after the map. If you give a wrong map type or the message
type on the input schema does not match the map, you just get no output
message and no error. Kind of the downside of dynamic mapping.

We did the whole untyped document dynamic mapping approach in our project.
I think it ended up being more work then we saved in the long run…

If you have any other questions just let me know.

Stephen W. Thomas
http://www.biztalkgurus.com


"BizTalk Benjamin" wrote:
[vbcol=seagreen]
> Hi Stephen,
>
> Thanks for the reply. I have solved it (and was just going to post a
> followup when i saw your reply) . There are a couple of things
>
> (1) the documentation has copied the code that lives behind an
> orchestration. I opened an odx in notepad and found the "transform" and
> "construct keywords. So we need to ignore the construct keyword since that is
> actually the name of the shape
>
> (2) the correct line in the message assignment shape is
> transform(Message_2) = Namespace.MapName(Message_1)
> There is no need for any other parts. Maybe you would need specific part
> names if you were using a multi part message
>
> Im currently working through the dynamic mapping where the orchestration has
> a member variable of type System.Type to hold the fully qualified map name.
> It passes the input file name (FILE.ReceivedFileName) to a helper class which
> then picks up the typename of the correct map and returns it to the orch
> which loads it up and does the mapping.
>
> I got it working for one message (it maps Message_A to Message_Common) but
> there are some bugs somewhere and for the second transformation (Message_B to
> Message_Common) it returns an empty result. I checked the maps and they are
> fine by themselves (test/validate).
>
> Im trying to get the helper class to log its results to a text file so i can
> trace the issue. Strangely, it refuses to write any text files (and doesnt
> throw any exceptions either). Its kinda weird cos I managed to get EntLib
> logging working for my main project so a simple file write should be a piece
> of cake. Anyway, thats deviating from the point and only serves to illustrate
> that we cant take anything for granted in BTS.
>
> Its well past midnight so i gotta go get some sleep.
>
> If you could share some of your code, that would be great. It could help me
> sort out my algorithm too.
>
> Cheers
> Benjy
>
> "Stephen W. Thomas" wrote:
>
BizTalk Benjamin

2005-08-25, 6:02 pm

Hi,
Just downloaded the sample. Will go through it and see. You're right, we
need to do a lot of checking for empty results and so on...

Thanks a lot

cheers
benjy


"Stephen W. Thomas" wrote:
[vbcol=seagreen]
> Hello.
>
> I got some sample code posted here:
> http://www.biztalkgurus.com/Samples...hestration.html
>
> I’ll do a better write up a little later today.
>
> If I remember correctly, we got an empty result a lot. In fact, I had to
> check for that after the map. If you give a wrong map type or the message
> type on the input schema does not match the map, you just get no output
> message and no error. Kind of the downside of dynamic mapping.
>
> We did the whole untyped document dynamic mapping approach in our project.
> I think it ended up being more work then we saved in the long run…
>
> If you have any other questions just let me know.
>
> Stephen W. Thomas
> http://www.biztalkgurus.com
>
>
> "BizTalk Benjamin" wrote:
>
Leo Gan

2005-08-29, 5:56 pm

We have such a problem:
we need more sofisticated validation with result more verbose then Yes/No.
I've made it in such a way:
In recieve port work a map with loose restrictions, that it can feed all
messages include erroneous msgs.
Then I use ValidateReader with a map with strict restrictions.
ValidateReader reports all errors in msg.


--
Leonid Ganeline,
BizTalk Developer
http://public.fotki.com/leogan/

"BizTalk Benjamin" <BizTalkBenjamin@discussions.microsoft.com> wrote in
message news:2A5CC8CC-BAC0-461A-A99C-AFD72E7C89EC@microsoft.com...
> Hi, I think I posted about this a while ago, but didnt get it resolved.
>
> I have a large number of Flat and XML files in different XSD's coming into
> my system. I need to convert them all into a common format and have maps
> for
> each. Additionally i have a custom schema validation component which i
> can
> call from an orchestration.
>
> Now I could put all the maps in a receive port and pick up the message in
> an
> orchestration, call the validator and go from there. But if any exceptions
> occur during the mapping, then i wont be able to handle them gracefully. I
> would rather put the mapping into an orchestration which i could surround
> with a try-catch and do some error handling.
>
> I came across an MSDN topic titled "Assigning to Transforms Dynamically",
> which seemed to touch on this issue but is difficult to understand. The
> supplied code snippet is rather weird (see below). Apparently you have to
> put
> it in a message assignment shape. I can put the if-else block in the
> shape,
> but BizTalk doesnt recognise the construct keyword. Additionally, there is
> no
> explanation as to what the different messages are and what the x1,x2,s1
> and
> s2 are.
>
> construct _responseMessage
> {
> transform (responseMessage.x1, _responseMessage.x2) =
> MapType(requestMessage.s1, _requestMessage.s2);
> }
>
> Has anyone used this before or have any other sample code which will let
> me
> call maps dynamically?
>
> Hoping someone can help
>
> cheers
> benjy
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com