Using BizTalk 2006 Mapping Engine

Home Page Forums BizTalk 2004 – BizTalk 2010 Using BizTalk 2006 Mapping Engine

Viewing 2 reply threads
  • Author
    Posts
    • #16933

      I am developing a system that does matching of various business documents. The documents that come into system could be in any format (EDI, CSV, TXT, XML etc.)
      I need to utilize BizTalk 2006 Mapping Engine to convert various document formats to XML and vice versa. For this I am trying to devise a simple solution that must require minimum of setup on my BizTalk 2006 Server machine (just the map & optionally pipeline assemblies deployment).

      I have setup a Receive Port and a Receive Location using FILE Adapter. The Receive Location polls a fixed forlder and looks for *.xml files. My system creates an XML file and puts it in the Receive Location folder. The XML file (reduced) schema is given below.

      <root>
      <inputfilelocation>\\fileserver\IncomingDocs\SampleFile.csv</inputfilelocation>
      <map>map name</map>
      </root>

      The Receive Location passes this XML to an Orchestration. Orchestration extracts the file path (<inputfilelocation> tag) and map name (<map>) tag. Now the Orchestration needs to use the specified map to transform the incoming file specified in <inputfilelocation> to another format.
      Since the file specified by <inputfilelocation> could be in any format (EDI, CSV and NOT just the XML), a Pipeline may also be required (correct?). This is done by using naming conventions and deriving out Pipeline name from Map name (e.g. PipelineName = "Pipeline.In." + <map name>; or something similar).

      However the problem in Orchestration code is to pass the document to the Pipeline. Like any other thing in Orchestration, the Pipeline expects an XLANGMessage object. I assume this requires the file to be in XML format but obviously the file format is not guaranteed to be XML (in fact the whole point of using Pipeline is to convert from an arbitrary format to XML so that mapping could be carried out!).
      I assume that once the document is converted by Pipeline, I could load the map and use a transform to do mapping.

      The questions I have are:

      1. Is this the correct way to utilize just the mapping engine of BizTalk 2006?
      2. Can an XLANGMessage object be initialized with ONLY XML format messages? How can I construct an XLANGMessage for a non-XML file?
      3. I may need to use a Pipeline at Send Port too (e.g. for CSV to EDI mapping where both the input and output formats are non-XML). Can I use the same mechanism at the Send Port as well?
      4. If this does not seem to be a proper solution, can anybody recommend a simple & practical approach to utilize BT06 Mapping Engine for translating different types of documents (EDI, CSV, TXT, XML etc.)?

      Thanks

    • #16938

      Yes, it sounds like you’d need to call a pipeline inside the Orchestration for you read in messages if they are not XML. 

       

      Here are my answers:

      1. Well, it’d not really say it’s just the mapping engine but really BizTalk as a whole.  Seems like a good fit.
      2. You should be able to construct an Xml Document inside an Orchestration and have it be anything.  Never done anything with XLangMessage, but it should allow you to do that as well.
      3. Sure. – but see below.
      4. See below.

       

      Let me get this right, you get a message in a location and then you go get a file at the location that message tells you?  Any way to just have the final document end up in your file location?  What you want to try to get to, is your Receive Locations to process your pipelines and convert into Xml.  Some on the Send side.  You can do both inside the Orchestration, but that’s just not really the best place for them. 

       

      If you can’t really change much, then I like your approach.  It makes sense to me and it should work for you.

       

      Are you just reading them using File IO?   If so, I’d make sure I was doing this inside a .net component I call rather than an expression shape.  Then you should be able to make that method return an XLang Message.

       

      Hope this helps.

      • #16943

        Unfortunately I disagree with Stephen on this one:

        The biztalk Mapping engine just uses Xsl Transformations to convert from one Xml format into another (mostly). The work of creating an Xml document from a non-Xml document is done by parsers in the Disassemble stage of the pipeline. To convert messages from one format to another they must be converted into Xml first.

        The mechanism of sending Biztalk a message with a file name that Biztalk then processes thru a pipeline seems like a lot of work  for not much gain. Why not have multiple receive locations all looking at a directory and using a file mask. So Xml files are *.xml, Excel files are *.xls, flat files are *.txt, etc. Each receive location would include a pipeline for handling a particular message type. If you wish to add a new message type simply add a new receive location.

        1. Is this the correct way to utilize just the mapping engine of BizTalk 2006?
        I don't think so

        2. Can an XLANGMessage object be initialized with ONLY XML format messages? How can I construct an XLANGMessage for a non-XML file?
        Biztalk is able to move a non-Xml message from Receive port thru an orchestration and out a send port without ever converting it into an Xml message. You only need to convert into Xml if you wish to use access data from within the document or to change the Xml format using the mapping engine. To use non Xml messages just use the Pass-Thru pipeline to accept messages.

        3. I may need to use a Pipeline at Send Port too (e.g. for CSV to EDI mapping where both the input and output formats are non-XML). Can I use the same mechanism at the Send Port as well?
        To convert from CSV to EDI you will need to write your own custom code to do this. You can either write generic code that can handle  any CSV to any EDI, but then you would need a mechanism (like a schema for defining the input and output formats). Or you could write specific code to convert from one specific CSV format to one specific EDI format.

        4. If this does not seem to be a proper solution, can anybody recommend a simple & practical approach to utilize BT06 Mapping Engine for translating different types of documents (EDI, CSV, TXT, XML etc.)?
        The Biztalk Messaging engine has been designed to do just this. However it does not have a many to many translation capability. It will accept a message in many formats using a disassembler to convert to Xml (this is extensible as you can write your own disassembler. It can then  process and transform the message and then send it using an Assembler to convert into many formats, again you can add you own assemblers.

        Can you explain a bit more about the overall purpose of your solution. What are you trying to do?

        • #16947

          Sorry greg; it took me a lot of time to complete my reply to Stephen's post so I couldn't check that your response had arrived. I guess I have already answered your question (Can you explain a bit more about the overall purpose of your solution. What are you trying to do?)

          As I specified in my reply, the main purpose of this type of design is to have less setup overhead. If I need to develop custom mapping, that would require development for each new file type / format. I need to deliver a solution where only a handful of mapping guys could deploy schemas & maps (& pipelines) to BizTalk Server 2006 machine, add some new map definitions in my system and the system just does its job (i.e. executes the maps for the files they are configured for).

          I have also considered multiple Receive Location setup. But with the number of maps this solution needs to support (2000+ maps), it seems an overkill (I may be wrong here). Setting up receive location with each new map defined in my system is also an overhead (though a one-time effort to write some code to setup necessary ports, locations & pipelines)

      • #16945

        Thanks Stephen, that really was helpful

        Yes; your understanding about the process design is correct. Let me just clarify the design a bit more.
        One-time setup steps.
        1. Create FILE Adapter Receive Port
        2. Create a Receive Location on this port to look for *.xml files in a fixed folder.
        3. Develop Orchestration.
        4. In BizTalk 2006, setup each xml file arriving at the specified receive location to go to Orchestration (xml file schema described in my earlier post).

        Here are the steps that my mapping team needs to perform for each new map.
        1. Develop Schemas, Map & optionally Pipelines using Visual Studio 2005 (BT06 Project).
        2. Deploy the resulting components in BizTalk 2006.

        Here's the Orchestration Logic
        1. Read XML file to extract & store <inputfilelocation> & <map name>.
        2. Read the contents of the file pointed to by the <inputfilelocation> tag (yes, there's a separate .NET component to do this which is invoked by Orchestration).
        3. Determine (using naming conventions etc.) if a pipeline is to be executed first.
        4. If pipeline is required, invoke pipeline (that's where I have problems since the document contents are not XML and pipeline execution "apparently" requiers an XmlDocument)
        5. Invoke map (transform)
        6. Determine (again, using naming conventions etc.) if a pipeline is to be executed before sending the document out to send port.
        7. Invoke pipeline if required.
        8. Send the document out via the single Send Port (again a FILE Adapter).
        Send Port uses the token %SourceFileName% to create an output file name so that its get easier for the system to relate an input file to the corresponding output file.

        Please let me know if this could be improved or replaced by a better alternative.
        The main objective behind designing such a setup is to reduce the amount of setup required on BizTalk 2006 Server. This allows our mapping team to continue to deploy new maps to our BT06 server without worrying about any other setup requirements there.

        I am not clear about some of the points you have made and would be glad if you could explain it more.
        "You should be able to construct an Xml Document inside an Orchestration and have it be anything" – Does this mean I can load an instance of System.Xml.XmlDocument with an arbitrary string or even a byte array? NO – I think I have misinterpreted your point here.
        "You can do both inside the Orchestration, but that’s just not really the best place for them" – Humm! why? performance problems? or better alternatives exists? or something else?

        Thanks a lot in advance

    • #16948

      Anon-

      Try IBM DatastageTX, formerly TSI Mercator. It compiles the parser and map into a single executable, which would fit the architecture you desire.

      – weak architect
       

      • #16952

        As Greg mentioned, this is by no means an ideal or best solution for a BizTalk point of view. 

         

        It is important to understand that you gain and give up by not loading the message though a Receive Location.  You give up persistence.  What you gain is, well, a little more flexibility as to the pick up location.  If you had 1,000’s of pickup locations that may not be known at any given time this makes sense.  If files are always going to be at \\somelocation\here\ then this might not be the right approach.

         

        This reminds me of something I did years ago with 04 Beta.  Needing the file loaded inside the Orchestration from some random location then sent via a preexisting .net component to a remote system.

         

        What I was getting at with this: “You can do both inside the Orchestration, but that’s just not really the best place for them”  Was in general, if you can do things differently you should.  A more standard approach is to call Send and Receive pipeline inside the ports and not the Orchestration. 

         

        I think it all rides on if you have a finite number of receive locations for your files.  If you do, then something like Greg is talking about is the right way to go.

      • #16955

        The messages passed thru Biztalk are a serializable .Net class that contain a message context (dictionary of name/value pairs) and a stream of bytes.

        In an orchestration you can receive a message of type XmlDocument. This does not mean the message has to be Xml. It means there is no MessageType on the messagebox subscription, so it will accept any type of message, even an image file. You will still have access to all the message context properties promoted by the adapter and pipeline components, including the FILE.ReceivedFileName if the message came from a file adapter.
        So your mechanism of sending an Xml file with the file name, which then uses a .Net component to read the file is not needed. You can simply have a single receive location with a file mask of *.* , a pass-thru pipeline and an orchestration accepting untyped messages, you will have achieved the same result.
        You could still use other receive locations on this receive port to accept xml files for example. Have a single receive location with the XmlReceive pipeline, which would determine the message type for you. In the orchestration you could check to see if BTS.MessageType property is set this would save you calling a receive pipeline first. Otherwise you can use your custom logic inside your orchestration to determine the pipeline to call to process the input file, perform some logic and and call the output pipeline and send the output. You still need to have a lot of configuration, that will enable you to determine which pipelines to call.

        Personally I would use as much of the functionality in the product as possible. The configuration setup is a one-off task that will probably be less effort than writing, testing and maintaining your own version of message routing.

        • #17069

          (I had been away for several days so couldn't see the latest response) Sorry for not making it clearer in earlier posts. In addition to passing the location of the file to map, the Xml is being used to pass other "context" information so I cannot pass the original file instead of Xml.

          I am now faced with a problem which might have an easy solution but is not obvious to me right now!

          In my Orchestration, I am using a .NET component to read the input file that gives me a byte array in the return value. I am using Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline to execute the pipeline. However this method requires an XLANGMessage object as its 2nd parameter. I do not know how to convery my byte array to an XLANGMessage object for passing it to my pipeline. I hope you could help.

          Thanks

          • #17076

            If I remember right, you can create a XLang Message by loading from String, Xml, or Stream.  Check the help guide to be sure.

             

            Might also want to note that you can not construct new messages per say in .net code.  You can only return messages or change messages passed in.  Make sense?

             

            I’d probably just use System.IO to load the message as a stream or something easer to work with than a byte array.

Viewing 2 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.