Re: Inserting entire XML message into database

Home Page Forums BizTalk 2004 – BizTalk 2010 Inserting entire XML message into database Re: Inserting entire XML message into database

#21353

Sure no problem.

I created a Stored Procedure to insert the xml message into a table like this:

CREATE PROCEDURE [dbo].[CreateLogEntry]
    @XmlMessage xml = null    

I have more parameters there but you get the picture.  Then I generated a schema from this procedure(the xml column comes out a string element).  Promote that element !!  Important step.

Then In my orchestration I have a message of type System.Xml.XmlDocument.  And the first thing I do after I receive my incoming message I do this in an expression shape:

MsgXmlLogMessage = MsgSalesOrderRcvd;  // Initialize the XmlDocument message

Then you need to Construct a message of the type CreateLogEntry (the schema we generated from the stored procedure).  Make sure in this map that you put some value into the Xml element because it is promoted and we set it in an Assignment shape but not in the map.  It will fail if you don’t set some dummy value in the map to assignit in an Assignment shape.

Then after the Transform shape put an Assignment shape and type this:

MsgRcvLogRequest.parameters.CreateLogEntry.XmlMessage = MsgXmlLogMessage.OuterXml;

Now you can just send this MsgRcvLogRequest to the SQL Send Adapter to execute the procedure.

 

Sorry for my english hope you understand if not I’ll try screenshots next 🙂