BizTalk Server Orchestration - Envelope and multiple documents.

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > February 2006 > Envelope and multiple documents.





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 Envelope and multiple documents.
CranCran77

2006-01-31, 7:58 am

I am trying to understand how I would create a message that would allow
me to specify some attributes that are common across all messages and
have a section as the "payload" which differs from message to message.

For example, I have several orchestrations that generate an output
message. I would like these orchestrations to generate an output Xml
Document that contains some routing/identification data at the header
(constant across all output documents) and a payload section that
contains variant document data from document to document.

How would I do this so that orchestration A can create:

<Document>
<Header>
<SequenceId>1</SequenceId>
<From>ServerA</From>
<Timestamp>20060131142432</Timestamp>
</Header>
<Data>
// Varies here based on whatever document is embeded from a prior
// message transform/creation shape.
</Data>
</Document>

And orchestration B would create a similar output document yet the Data
section would vary in the type of XML document structure embeded?

These documents all will go to a final stage in my environment where
the document header is extracted and examined. The data parsed and the
payload (data area) will be transmitted to the remote system in order
based on the sequenceid from the header.

Tomas Restrepo \(MVP\)

2006-01-31, 6:59 pm

Hi Cran,

>I am trying to understand how I would create a message that would allow
> me to specify some attributes that are common across all messages and
> have a section as the "payload" which differs from message to message.
>
> For example, I have several orchestrations that generate an output
> message. I would like these orchestrations to generate an output Xml
> Document that contains some routing/identification data at the header
> (constant across all output documents) and a payload section that
> contains variant document data from document to document.
>
> How would I do this so that orchestration A can create:
>
> <Document>
> <Header>
> <SequenceId>1</SequenceId>
> <From>ServerA</From>
> <Timestamp>20060131142432</Timestamp>
> </Header>
> <Data>
> // Varies here based on whatever document is embeded from a prior
> // message transform/creation shape.
> </Data>
> </Document>
>
> And orchestration B would create a similar output document yet the Data
> section would vary in the type of XML document structure embeded?


This is perfectly possible, and BizTalk fully supports it. In your case, you
want to apply the envelope pattern:

1- You create a base schema that describes the generic document (i.e. the
envelope). it contains all header fields and the Data record, containing an
<xsd:any/>, to represent that it can contain any arbitrary XML fragment.
Since you are not going to involve pipelines (from your description), one
thing to take into account is that you probably don't want to mark this as
an Envelope Schema in BizTalk, so that your pipelines don't process it.

2- Create your document schemas normally.

Then, you can create instances of your documents that are enveloped in the
following way:
- Assume you have a typed BizTalk message in your orchestration of the
document type. You want your orchestration to pack this into a message of
the envelope type.
- Now define in your orchestration a message of the envelope type
- Now, use a construct shape to initialize your enveloped document. In
there, you can initialize it either using an message assignment shape, or a
transform shape. The basic rule here is, you want to copy your existing
original document directly into the <Data> node of your envelope message.
This is possible in a message assignment shape because biztalk basically
allows you to assign any XmlDocument/XmlElement instance directly to the
node, so just converting your existing document message to an XmlDocument
via a trivial .NET component allows you to do this in a snap.

I'm sure this didn't come out as understandable as I hoped, but I can assure
you it works. Let me know if you have trouble decyphering it


> These documents all will go to a final stage in my environment where
> the document header is extracted and examined. The data parsed and the
> payload (data area) will be transmitted to the remote system in order
> based on the sequenceid from the header.


Perfectly valid. In fact, I've applied this technique with a lot of success
before (here's one case I used it:
http://www.winterdom.com/weblog/archives/000565.html)


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-01-31, 6:59 pm

I may have gotten something wrong in my code but I was creating this
output document. The output file was saved as follows:

<?xml version="1.0" encoding="utf-8"?>
<ns0:Document xmlns:ns0="http://EnvelopeMessage">
<Header>
<ns0:ControlRecord xmlns:ns0="http://ControlRecord">
<SequenceId>1</SequenceId>
<Server>shqsr17a</Server>
</ns0:ControlRecord>
</Header>
<Data>
<ns0:WMMBID02 xmlns:ns0="http://WMMBID02.V3">
<EDI_DC40>.... more junk here </EDI_DC40>
</ns0:WMMBID02>
</Data>
</ns0:Document>

But when my sequencer tries to read it in, I get strange results in my
debugger view window and when I look at HAT it said something regarding
that part of message was not in the database or something.

Am I doing something incorrect?

Tomas Restrepo \(MVP\)

2006-01-31, 6:59 pm

>I may have gotten something wrong in my code but I was creating this
> output document. The output file was saved as follows:
>
> <?xml version="1.0" encoding="utf-8"?>
> <ns0:Document xmlns:ns0="http://EnvelopeMessage">
> <Header>
> <ns0:ControlRecord xmlns:ns0="http://ControlRecord">
> <SequenceId>1</SequenceId>
> <Server>shqsr17a</Server>
> </ns0:ControlRecord>
> </Header>
> <Data>
> <ns0:WMMBID02 xmlns:ns0="http://WMMBID02.V3">
> <EDI_DC40>.... more junk here </EDI_DC40>
> </ns0:WMMBID02>
> </Data>
> </ns0:Document>
>
> But when my sequencer tries to read it in, I get strange results in my
> debugger view window and when I look at HAT it said something regarding
> that part of message was not in the database or something.
>
> Am I doing something incorrect?


The document looks OK. how are your schemas defined? Are you using any
particular adapter and pipeline to pick it up, or are you using direct
binding?


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-01-31, 6:59 pm

Ok, finally found part of my problem. What I am having trouble is how
do I use xpath on my input message to extract the child tree from
Header. If I use:


xpath(MyMessage,"/*[local-name()='Document']/*[local-name()='Header']")

This returns the block:
<Header>
<ns0:ControlRecord><SequenceId>1</SequenceId></ns0:ControlRecord>
</Header>

I would rather want it to return so it is properly assigned to my
schema that this any argument reflects would be:

<ns0:ControlRecord><SequenceId>1</SequenceId></ns0:ControlRecord>

What am I missing in my xpath call to get the child tree?

Tomas Restrepo \(MVP\)

2006-01-31, 6:59 pm

Hi CranCran,

> Ok, finally found part of my problem. What I am having trouble is how
> do I use xpath on my input message to extract the child tree from
> Header. If I use:
>
>
> xpath(MyMessage,"/*[local-name()='Document']/*[local-name()='Header']")
>
> This returns the block:
> <Header>
> <ns0:ControlRecord><SequenceId>1</SequenceId></ns0:ControlRecord>
> </Header>
>
> I would rather want it to return so it is properly assigned to my
> schema that this any argument reflects would be:
>
> <ns0:ControlRecord><SequenceId>1</SequenceId></ns0:ControlRecord>
>
> What am I missing in my xpath call to get the child tree?


Ahh, no problem either. The following should work:

xpath(MyMessage,"/*[local-name()='Document']/*[local-name()='Header']/*[1]")


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-01-31, 6:59 pm

Have any other shortcuts and neat concepts? <grin>.

What is required and how would I go about having my orchestration
submit an email to a mailbox under an error condition?

Tomas Restrepo \(MVP\)

2006-01-31, 6:59 pm

Hi

> Have any other shortcuts and neat concepts? <grin>.


Well, you might find a few interesting things on my weblog
(http://www.winterdom.com/weblog), but you should definitely check out Alan
Smith's "Bloggers Guide To BizTalk" [1]; it's probably the single best
resource on biztalk right now.

> What is required and how would I go about having my orchestration
> submit an email to a mailbox under an error condition?


You could use the SMTP adapter for this, if you wanted, and then use
Exception handlers on scopes to detect particular errors.

http://www.gotdotnet.com/workspaces...18-2c385d8e3eaa
--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-02-01, 5:56 pm

Tomas, have you ever worked with IDOCs and SAP and used this kind of
mechanism? I got a strange MySAP adapter message where it said: EDI:
SEGNAM in data record default
....

I looked in the XML output and the only thing I noticed was that
instead of being 1 single line that now it seems to have new line
characters in it. I'm not sure why this is happening, do you? If I
cannot get this to be a single line (probably because of the way I am
having to construct the message as string), then I may have to abandon
this entire concept and go back to a sequential convoy ... I dont
want to because of the performance implications. Can you help me out?

Tomas Restrepo \(MVP\)

2006-02-01, 5:56 pm

> Tomas, have you ever worked with IDOCs and SAP and used this kind of
> mechanism?
> I got a strange MySAP adapter message where it said: EDI:
> SEGNAM in data record default
> ...
>
> I looked in the XML output and the only thing I noticed was that
> instead of being 1 single line that now it seems to have new line
> characters in it. I'm not sure why this is happening, do you? If I
> cannot get this to be a single line (probably because of the way I am
> having to construct the message as string), then I may have to abandon
> this entire concept and go back to a sequential convoy ... I dont
> want to because of the performance implications. Can you help me out?


I haven't worked with it, but if it's an xml document, the newlines
shouldn't be a problem. It might be a problem with the idoc to xml
conversion, though. If you post the relevant document, maybe one of us can
offer some advice


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-02-01, 5:56 pm

Ok, will do that in a few moments. If I may also ask I posted a
problem with references in this newsgroup. I am getting a strange
error and not sure if you've seen it before. The error in the event
log is the following:

Failed while creating a Project4.OrchTest service.

Exception type: ServiceCreationException
Source:
Target Site:
Help Link:
Additional error information:

Object type cannot be converted to target type.

Exception type: ArgumentException
Source: mscorlib
Target Site: Void InternalSetValue(System.Object, System.Object,
System.Reflection.BindingFlags, System.Reflection.Binder,
System.Globalization.CultureInfo, Boolean, Boolean)
Help Link:
Additional error information:

The way I have structured my solutions again is the following:

Project1 - Contains only schemas that has been deployed.
Project2 - Contains database poller.
Routes documents to the right orchestration.
Project3 - Processes document type A
Project4 - Processes document type B

Now Projects 2, 3, and 4 reference Project1. Project 2 also references
projects 3 and 4 because it needs that in order for me to see and use
the start orchestration shape. Another strange behavior I get is when
I compile Project2 is that it complains that it already sees the
symbols that are contained in Project1.

How can I avoid these issues and avoid this log error message???

Tomas Restrepo \(MVP\)

2006-02-02, 5:51 pm

> Ok, will do that in a few moments. If I may also ask I posted a
> problem with references in this newsgroup. I am getting a strange
> error and not sure if you've seen it before. The error in the event
> log is the following:
>
> Failed while creating a Project4.OrchTest service.
>
> Exception type: ServiceCreationException
> Source:
> Target Site:
> Help Link:
> Additional error information:
>
> Object type cannot be converted to target type.
>
> Exception type: ArgumentException
> Source: mscorlib
> Target Site: Void InternalSetValue(System.Object, System.Object,
> System.Reflection.BindingFlags, System.Reflection.Binder,
> System.Globalization.CultureInfo, Boolean, Boolean)
> Help Link:
> Additional error information:
>
> The way I have structured my solutions again is the following:
>
> Project1 - Contains only schemas that has been deployed.
> Project2 - Contains database poller.
> Routes documents to the right orchestration.
> Project3 - Processes document type A
> Project4 - Processes document type B
>
> Now Projects 2, 3, and 4 reference Project1. Project 2 also references
> projects 3 and 4 because it needs that in order for me to see and use
> the start orchestration shape. Another strange behavior I get is when
> I compile Project2 is that it complains that it already sees the
> symbols that are contained in Project1.
>
> How can I avoid these issues and avoid this log error message???


I'm not sure exactly what is going on here with the projects. Are you using
project or direct file references?

Other than that, your "Object type cannot be converted to target type"
exception might be triggered by a versioning issue. Perhaps the wrong
assembly is getting picked up?


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


CranCran77

2006-02-02, 5:51 pm

It was a naming convention issue with some messages in different
orchestrations where the orchestration namespace was the same. For
example:

ProcessA orchestration namespace: MyCompany.Orchestration
ProcessB orchestration namespace: MyCompany.Orchestration

In both orchestrations it referenced the same message type and that was
why it was giving me these errors.

When I renamed my orchestration namespaces to the following, it went
away:

MyCompany.Orchestration.ProcessA
MyCompany.Orchestration.ProcessB

CranCran77

2006-02-02, 5:51 pm

I just posted a new thread "Send Shape w/Exception Handling". Since
you've been very helpful, would you mind, if you can help me, answer my
question there? I wanted to break away from this topic as I think
we've answered it and felt a new thread made more sense.

Thanks Tomas!
Chris

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com