I was in the process of posting to one of the newsgroups this afternoon when I saw that someone else had beaten me to it, and posted on the exact same topic, Envelope schemas and mapping.
It's a fairly common scenario - a message needs to be split, with common 'header' information being included in each message. I had thought that it would be possible to do this in a pipeline, and I've found various posts referring to this situation (see end of post for references), none of which really answered the question.
To demonstrate this in action I'll use the classic customer / order example. I have a starting message which contains header and body information, and an orchestration that uses the individual order messages, with the customer data being inserted into each message, as shown below:
Original message:
<CustomerOrdersResponse>
<Customer>...</Customer>
<Orders>
<Order>...</Order>
<Order>...</Order>
</Orders>
</CustomerOrdersResponse>
Messages as required by Orchestration:
<CustomerOrder>
<Customer>...</Customer>
<Order>...</Order>
</CustomerOrder>
I have defined three schemas to accomodate this - Customer, Order and CustomerOrder:
Customer:
<Customer>
<Firstname>John</Firstname>
<Lastname>Doe</Lastname>
<Age>30</Age>
</Customer>
Order:
<Order>
<Item>1</Item>
<Qty>2</Qty>
</Order>
CustomerOrder:
<CustomerOrder>
<Customer>...</Customer>
<Order>...</Order>
</CustomerOrder>
The first thing to do try is a simple splitting of the messages using an envelope schema. Create a new schema, set its Envelope property to true, and the Body XPath of the root node to the xpath that points to the root of the collection - in this case to the <Orders/> node. The sample xml message below shows the relationship between envelope and body parts:
Envelope
<CustomerOrdersResponse> (Set Body XPath property of this node to xpath of Orders node below)
<Customer>...</Customer>
- - - - - - - - - - - - - - - - -
Body
<Orders>
<Order>...</Order>
<Order>...</Order>
</Orders>
- - - - - - - - - - - - - - - - -
</CustomerOrdersResponse>
When a message that conforms to an envelope is processed in an (XML) pipeline, the envelope is discarded, and the repeating body records are split out into separate messages. The message above would be converted into two <Order/> messages. So far, so simple.
The problem now is how to get a CustomerOrder message out of the above, rather than the Order alone.
My first idea was to use a map to convert the original message to a collection of CustomerOrder messages, and redefine the envelope schema to use the new message:
<CustomerOrders>
<CustomerOrder>
<Customer>...</Customer>
<Order>...</Order>
</CustomerOrder>
<CustomerOrder>
<Customer>...</Customer>
<Order>...</Order>
</CustomerOrder>
<CustomerOrders>
I figured that if I put this map into a send pipeline, then I could send the original CustomerOrderResponse message out through this pipeline, converting it into a CustomerOrders message, which would then be picked up by a receive location which would extract the individual CustomerOrder messages.
Which is where it all goes wrong.
If you try and do this, you'll get an exception thrown by the send pipeline saying that "Document type "CustomerOrder" does not match any of the given schemas." I looked around, and found that someone else had had a similar issue, and concluded that mapping to an Envelope schema is not possible within a pipeline. Which brings me back to where I started, as this is exactly the issue that Duncan Millard and I collided on whilst posting to microsoft.public.biztalk.general.
You can map to Envelope schemas within an orchestration, and it turns out that this is how we are getting around the problem - the original CustomerOrdersResponse message is mapped to CustomerOrders within an orchestration, sent out through a send pipeline (without further mapping), then picked up by a receive location that splits out the CustomerOrder messages.
There is an alternative method - using XPath within a loop / expression combination. This may well be better in certain situations, but it seems a shame not to use the inherent envelope functionality. I believe it may also be possible using some custom pipeline magic, and Stephen Thomas' blog posting (see below) has some interesting stuff on property promotion / demotion tricks, but none of it seems very simple.
Does anyone know of an easier way to do all of this in one pass?
References:
How to split an XML message in BizTalk 2004 using Document & Envelope Schemas (Jan Tielens)
BizTalk Server will split up your documents for you. (Scott Woodgate)
Property Promotion and Demotion in BizTalk 2004 (Stephen Thomas)
Looping around Message Elements (Darren Jefford)
Thursday, December 09, 2004
Subscribe to:
Post Comments (Atom)

7 comments:
Hi Hugo,
I ended up using the xpath method described in Darren Jefford's blog. Like you said, a pain not to use the built in functionality... Especially when there's no obvious solution as to why it doesn't work.
The other solution, that I've not tried yet, is to hardcode the "Customer" schema into the envelope instead of importing it (yuk). In my case this probably wouldn't work because I rely on xs:imported common datatypes too and they wouldn't resolve.
I did wonder if it was an assembly loading issue, because in the mapper the destination schema is only defined by a typename, not a fully qualified assembly reference. I tried to change that to a fully qualified type name and the mapper barfed. Shame :-) I also logged all bindings with fuslogvw and there was no "failure to load assembly" kind of issues. Ah well.
Finally - can you sort out an RSS feed for your blog so I can subscribe to it? (I moved my blog away from Blogger to GeeksWithBlogs for this reason...).
Cheers,
Duncan Millard
(http://geekswithblogs.net/dmillard)
Hi Gugo,
see my implementation for loop/Xpath method,
http://biztalkers.blogspot.com/2005/01/complex-message-handling-in-biztalk.html
you post is really great
Interesting blog. I have a xml resource blog.
Great bit of blogging on your site! If you get a chance look at my site
A typical dictionary definition of hypnosis states that it is: a state that resembles sleep but that is induced by suggestion. However, anyone who has tried hypnosis (and any self respecting hypnotist) will tell you that this is a very simplistic view of the subject!
A much better description comes from the Free Online Dictionary which states that hypnosis is: an artificially induced state of consciousness, characterised by heightened suggestibility and receptivity to direction. So what does this mean and how can it be used to your advantage?
Well, the subject of hypnosis has been discussed and pondered since the late 1700s. Many explanations and theories have come and gone though science, however, has yet to supply a valid and well-established definition of how it actually happens. It's fairly unlikely that the scientific community will arrive at a definitive explanation for hypnosis in the near future either, as the untapped resources of our 'mostly' uncharted mind still remain something of a mystery.
However, the general characteristics of hypnosis are well documented. It is a trance state characterized by extreme suggestibility, deep relaxation and heightened imaginative functioning. It's not really like sleep at all, because the subject is alert the whole time. It is most often compared to daydreaming, or the feeling you get when you watch a movie or read a captivating book. You are fully conscious, but you tune out most of the outside world. Your focus is concentrated intensely on the mental processes you are experiencing - if movies didn't provide such disassociation with everyday life and put a person in a very receptive state then they would not be as popular (nor would TV advertising be as effective!). Have you ever stated that a film wasn't great because you just couldn't 'get into it'???
This works very simply; while daydream or watching a movie, an imaginary world becomes almost real to you because it fully engages your emotional responses. Such mental pursuits will on most occasions cause real emotional responses such as fear, sadness or happiness (have you ever cried at a sad movie, felt excited by a future event not yet taken place or shivered at the thought of your worst fear?).
It is widely accepted that these states are all forms of self-hypnosis. If you take this view you can easily see that you go into and out of mild hypnotic states on a daily basis - when driving home from work, washing the dishes, or even listening to a boring conversation. Although these situations produce a mental state that is very receptive to suggestion the most powerful time for self-change occurs in the trance state brought on by intentional relaxation and focusing exercises. This deep hypnosis is often compared to the relaxed mental state between wakefulness and sleep.
In this mental state, people feel uninhibited and relaxed and they release all worries and doubts that normally occupy their mind. A similar experience occurs while you are daydreaming or watching the TV. You become so involved in the onscreen antics that worries and everyday cares fade away, until all you're focused on is the TV. In this state, you are also highly suggestible. That is why when a hypnotist tells you do something under trance; you'll probably embrace the idea completely. However, your sense of safety and morality remain entrenched throughout the experience and should either of these be threatened you immediately wake!
A hypnotist can not get you to do anything you don't want to do.
So while in such a state, when we are highly suggestible and open to new beliefs, a skillful hypnotist, whether in person or via a recording, can alter life-long behaviours and even give us new ones! personal development
Neurolinguistic Programming
In the early 1970s in America Richard Bandler, then a young college student studied the work of Fritz Perls and later Virginia Satir and found that he could reproduce their high-level therapy skills to a degree that even surprised him. Bandler seemed to have a natural ability to mimic (model) the language patterns by Virginia and Fritz.
At the University of California at Santa Cruz, Bandler who was well versed in the teachings of patterns in mathematics and computers teamed up with a college professor, John Grinder to help him understand the processes that were at work. Soon Bandler and Grinder, who used what he knew about patterns in linguistics, created a new model for personal growth called NeuroLinguistic Programming.
Bandler and Grinder had set out to model the hypnotic skills of Milton Erickson. They had astounding results. They built a communication model about human "thinking" and "processing" and used that model of how we see images, hear sounds, reproduces smells and tactile experiences in our mind to track and model the structure of subjective experiences.
Sounds very complicated but really it works very simply. Here is an example as used by Paul McKenna - probably the best & most successful hypnotist in the world.
Close your eyes and think of a negative memory. Become involved in the situation as best as you can. Feel the emotions that you felt, see the things you saw and hear the things you heard.
Now take that memory and project it onto a mental screen seeing yourself in the picture. Put a frame around the picture and view it as if it is an old photograph. Next drain all the colour from the picture and shrink the screen to the size of a matchbox.
Have the feelings associated with the picture decreased in any way?
Another good example of NLP involves Anchors. Have you ever smelt a certain perfume or aftershave and had it remind you of a certain person or situation? Gone to a certain place that brings feelings long forgotten flooding back? Or been in any situation that creates emotional responses that would not normally be associated with it? Well if you can answer yes to any of these then you have experienced anchors. Some anchors are associated with positive feelings and some with negative emotions. However, you should be aware that anchors can be consciously installed or already existing ones altered. Here is an example:
Think of a time when you were really happy. If you can't think of one then imagine something that would make you feel really happy. See what you would see, hear what you would hear and feel what you would feel. Really get into the picture and try to experience it as though it were happening now.
Now brighten the colours and make them richer. Increase the volume. Make the picture bigger, brighter, louder. That's it and more and more....
Now press your first finger against your thumb and fully experience your happy feelings. Do this everyday for 2 weeks and you will create an anchor that will instantly recreate these feelings. Whenever you want to feel like that again just press your thumb and first finger together and wham the feelings will come flooding back! Don't believe me? Just try it and see!!! self hypnosis
black mold exposureblack mold symptoms of exposurewrought iron garden gatesiron garden gates find them herefine thin hair hairstylessearch hair styles for fine thin hairnight vision binocularsbuy night vision binocularslipitor reactionslipitor allergic reactionsluxury beach resort in the philippines
afordable beach resorts in the philippineshomeopathy for eczema.baby eczema.save big with great mineral makeup bargainsmineral makeup wholesalersprodam iphone Apple prodam iphone prahacect iphone manualmanual for P 168 iphonefero 52 binocularsnight vision Fero 52 binocularsThe best night vision binoculars here
night vision binoculars bargainsfree photo albums computer programsfree software to make photo albumsfree tax formsprintable tax forms for free craftmatic air bedcraftmatic air bed adjustable info hereboyd air bedboyd night air bed lowest pricefind air beds in wisconsinbest air beds in wisconsincloud air beds
best cloud inflatable air bedssealy air beds portableportables air bedsrv luggage racksaluminum made rv luggage racksair bed raisedbest form raised air bedsaircraft support equipmentsbest support equipments for aircraftsbed air informercialsbest informercials bed airmattress sized air beds
bestair bed mattress antique doorknobsantique doorknob identification tipsdvd player troubleshootingtroubleshooting with the dvd playerflat panel television lcd vs plasmaflat panel lcd television versus plasma pic the bestThe causes of economic recessionwhat are the causes of economic recessionadjustable bed air foam The best bed air foam
hoof prints antique equestrian printsantique hoof prints equestrian printsBuy air bedadjustablebuy the best adjustable air bedsair beds canadian storesCanadian stores for air beds
migraine causemigraine treatments floridaflorida headache clinicdrying dessicantair drying dessicantdessicant air dryerpediatric asthmaasthma specialistasthma children specialistcarpet cleaning dallas txcarpet cleaners dallascarpet cleaning dallas
vero beach vacationvero beach vacationsbeach vacation homes veroms beach vacationsms beach vacationms beach condosmaui beach vacationmaui beach vacationsmaui beach clubbeach vacationsyour beach vacationscheap beach vacations
bob hairstylebob haircutsbob layeredpob hairstylebobbedclassic bobCare for Curly HairTips for Curly Haircurly hair12r 22.5 best pricetires truck bustires 12r 22.5
Post a Comment