Home Page › Forums › BizTalk 2004 – BizTalk 2010 › storing xml file in database using sql adapter
- This topic has 12 replies, 1 voice, and was last updated 9 years, 5 months ago by
community-content.
-
AuthorPosts
-
-
August 16, 2006 at 6:06 PM #15324
Hi,
Here’s the scenario. I receive an xml in my orchestration and to some point I want to store this whole xml file in my database (in a image field). My feeling is that I cant use the sql adapter for this purpose? Am I rigth?
Do I have to create a class in .net and call it in an expression control in order to do that ?
Thanks for your help.
-
August 17, 2006 at 3:14 PM #15325
Thanks Greg for your reply.
Let say I set my db column to ntext and I use the standard sql adapter, how can I store the whole xml in a column?
From what I have seen, the sql adapter send port is normally used to match a message field with a table field. In my case I want to match a whole message with a table field. Do you have an example or a description of the process to achieve that?
Thanks
-
August 18, 2006 at 11:43 AM #15326
Great.
That’s what I was looking for.
Thanks.
-
August 29, 2006 at 1:41 PM #15327
i receive a xml message through a http receive port which i want to store in database field.
i prepared a xmldocument object and then assigned incoming message to it.
then i added a sql adapter of type send receive and then in procedurerequest part of message for sql adapter i distinguished the field ntext ie xmlmessage in my case.then i assigned outerxml to message.parameters.reqroot.xmlmessage.
but it gave me a error that message is not initialized.so in construct block i added a transform where i mapped a field required.then i added a message construct block where this distinguished field of ntext was assigned to xmldoc.outerxml.
i deployed it but after running it gave me a error
Uncaught exception terminated service Taylor_insert_xml.InsertXml(e5d8d7a6-f73d-3007-261d-3404f0ad5d24), instance e52cabcb-c693-45c5-891c-d49a3f18da2a
A failure occurred while evaluating the distinguished field proc_Insert_Taylor_xml.xmlmessage against the message part data. The message part data does not contain at least one of the nodes specified by the XPath expression (listed below) that corresponds to the distinguished field. The cause for this error may be that the message part data has not been initialized or that the message part data does not conform to the message part schema. Ensure that the message part data is initialized correctly.
XPath expression: /*[local-name()=’Sendtaylor’ and namespace-uri()=’http://test_Ins_sql_taylor’%5D/*%5Blocal-name()=’proc_Insert_Taylor_xml’ and namespace-uri()=’http://test_Ins_sql_taylor’%5D/@*%5Blocal-name()=’xmlmessage’ and namespace-uri()=”]please help its urgent.
in your eg you have shown sqlupdatemessage.ntextfield.
i am not able to access like that
message.parameters.storeprocname.ntextfield
-
August 30, 2006 at 11:43 AM #15328
hi,
thanks a lot for help
earlier i had a issue of storing a xml directly into a field in database.i am able to do it.
thanks for the help.
now later i want to use this xml message stored in database to insert an order in other system.
how should i query this xml message stored according to orderid using sql adapter of type receive.
i tried by writing a stored procedure and using sql adapter of type recv.the schema generated gives a error that one of types is not defined.as the message contains xml itself.
i was not able to select that data using xml elements,xmldata or xml auto as it contains an entire xml with namespace.
after getting this xml message in db as one field in schema, i want to contruct the message for schema to which xml in database corresponds.
then after constructing that message i will be able to process it further.
please help it is urgent.
-
August 30, 2006 at 11:43 AM #15329
Here’s a good link about how to create a message and initialaze it. It help me allot.
[url]http://www.objectsharp.com/Blogs/matt/archive/2004/11/09/1009.aspx[/url]
On my side I have created a helper class to construct new empty and initialized message. By the way if you use SQL Server 2005, I suggest you use the \”xml\” new field type to store xml document.
-
September 1, 2006 at 11:17 AM #15330
Hi,
I am also stuck up with same problem as you mentioned above.
I got one xml message as response of SQL request-response adapter.
I have transformed this message to another schema. And then stored it in xmlDoc variable. Now in order to send message to another system, i want to send one field and whole XML message. So i have constructed it with Transforming and by setting the value of xmlMessage as \”Empty\” in transform and then assiging the distinguished field of type nText a value of xmlDoc.outerXML.But i get the same error as
\”A failure occured while evaluating the distinguished field proc_selct.newXML against the message part data.The message part data does notcontain at least one of the nodes specified by the Xpah expression that corresponds to the distinguished field.\”
I have also tested this by creating the a dummy message and then constructing real message but it gives the same error.
Also i have tested it by giving a default value to distinguished field but also it gives the same error.
How can i solve this problem?
Plz help as it urgent.
Thanks in advanced.
-
August 17, 2006 at 5:16 PM #15331
I’d probably use a helper .net class and call it inside the Orchestration. This way, I’d just use pure .net to insert the Xml into any column type you like in SQL.
-
August 16, 2006 at 7:29 PM #15332
If you store the Xml as ntext datatype in SQL Server, you can use the standard SQL Adapter.
If you specifically want to use an image datatype then you could try the SQL Server BLOB adapter:
[url]http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=189360ED-B216-45D2-B11A-B42828A3697D[/url]-
August 17, 2006 at 7:30 PM #15333
You can also do this in the orchestration.
Declare a orchestration variable of type XmlDocument
Assign the message you wish to store to this variable.
Then assign the OuterXml string of this variable to the nText field in the SQLMessagexmlDocVar = MessageToStore;
SQLUpdateMessage.nTextColumnField = xmlDocVar.OuterXml;Make the nTextColumnField a distinguished field or you can use the xpath function to assign the value. Do not make nTextColumnField a promoted property as this limits the size to 256 bytes.
-
August 29, 2006 at 7:30 PM #15334
To set a distinguished field the Xml message must contain the node referenced.
I suspect that you do not create the xmlmessage node in your map.
If you open the map select the xmlmessage node in the destination, scroll down the properties and set the Value property to \”EMPTY\”.This will produce an output message containing the node:
<xmlmessage>EMPTY</xmlmessage>This will be overwritten in the message assignment shape when you assign the xmlDocument.OuterXml to the distinguished field.
-
August 30, 2006 at 8:15 PM #15335
You need to do the opposite process to retrieve the message from SQL.
Query the database using the SQLAdapter – the xml message is returned in a single field.
xmlDoc.LoadXml(SQLQuery.XmlMessageField);
newMessage = xmlDoc;where xmlDoc is a XmlDocument variable and SQLQuery.XmlMessageField is the distinguished field in the SQL message containing the xml message.
-
September 1, 2006 at 8:40 PM #15336
Can you email me your project
-
-
-
-
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.