how to construct the initial select message?

Home Page Forums BizTalk 2004 – BizTalk 2010 how to construct the initial select message?

Viewing 1 reply thread
  • Author
    Posts
    • #24949

      I am very new in biztalk.  This is my second biztalk project. I am trying to create a biztalk project with basic functions to send select query to a sql server database and receive the result of table data. 

      I have generated schemas for send select query and receive the response; I have also created the send-receive port as well as the send and receive messages. 

      But I don’t know how I can start this orchestration.  An orchestration cannot start with a send message, can it? 

      Any help will be highly appreciated.

    • #24950

      Hi.

      Do you use SQL adapter or WCF-SQL?

      For creating message which is sent to SQL as request – I generate an instance of schema – of a request, and do next steps:

      define some XML document variable. xDocument.LoadXml(your generated instance);

      msgSqlRequest = xDocument;

      msgSqlRequest (*) = some incoming messages for setting context(*);

      Send this msgSqlRequest  through your defined port to SQL, and get response. If your stored procedures has no incoming parameters – it will be an empty (without parameters) XML, else you should put some parameters in XML fields.

      Also – it’s a bit different while you want to use polling – when your orchestration started on some changed data in SQL Server tables.

      • #24983

        [quote user="Zx7R"]

        Hi.

        Do you use SQL adapter or WCF-SQL?

        [/quote]

        Yes, I use WCF-SQL.

        [quote user="Zx7R"]

        define some XML document variable. xDocument.LoadXml(your generated instance);

        msgSqlRequest = xDocument;

        msgSqlRequest (*) = some incoming messages for setting context(*);

        [/quote]

        sorry for being naive, but where do I define and load the xml instance? 

         

        • #24986

          Hi Iberan,

           

             I can answer your above questions on behalf of Yonathan:

          1) You define the variable xDocument (of type System.XML.XmlDocument) in your orchestration, and load the XML instance into that variable in an Expression shape.

          2) You assign xDocument to the message msgSqlRequest in a Message Assignment shape.

           

              Best,

           

              Daniel.

           

          • #24991

            [quote user="xman71"]

            1) You define the variable xDocument (of type System.XML.XmlDocument) in your orchestration

            [/quote]

            Daniel,

            Thank you for replying.  But how exactly to define the variable in orchestration?  I have created messages in orchestration but those messages seem to serve as message types. 

            Lynn

            • #24992

              Hi Lynn,

               

                  Open your Biztalk project in Visual Studio, then open your orchestration file, the Orchestration View tab will come up, and you will see a “Messages” folder in the top panel. Right-click on Messages and select New Message option, and specify System.XML.XmlDocument in the Message Type property (in the Properties tab).

               

                  Daniel.

               

              • #24993

                [quote user="xman71"]

                Hi Lynn,

                 

                    Open your Biztalk project in Visual Studio, then open your orchestration file, the Orchestration View tab will come up, and you will see a “Messages” folder in the top panel. Right-click on Messages and select New Message option, and specify System.XML.XmlDocument in the Message Type property (in the Properties tab).

                 

                    Daniel.

                 

                [/quote]

                Denial,

                Ok.  I have created serveral messages like that.  But those messages seem to serve as message type.  how do you use it as an instance or variable so that you may assign the initial message to it?

                Thank you very much!

                Lynn

                • #24995

                  Hi Lynn,

                   

                     I assume you have a schema associated with your initial message, right? So you can generate an instance of that schema from your project, by first right-clicking on the schema file and choosing Properties option, this will bring the up the schema’s Property Pages window, specify the value for the Output Instance Filename property in the General section, save your changes. Then right-click again on the schema file and choose Generate Instance option. Go and file the XML file generated that represents the instance of your schema, copy its contents, then in the Expression shape, write the following line of code:

                  xDocument.Load(“<Contents of XML file instance>“);

                     Where you replace <Contents of XML file instance> with what you copied form the schema instance file…

                     Then, further down in your orchestration, you can assign this variable to your message in a Message Assignment shape, like this:

                  messageRequest = xDocument;

                   

                     Daniel.

                   

                  • #24996

                    ok.  when i tried the following code:

                    Message_1.Load(‘<ns0:Root xmlns:ns0=”http://BizTalkMonthlyUpdateSalesExpiration.SchemaInitialSelectMessage”&gt; <ns1:Select xmlns:ns1=”http://schemas.microsoft.com/Sql/2008/05/ViewOp/dbo/View_biztalk_salesExpiration_getOR_RYG_ADP”&gt; <ns1:Columns>ns0:Columns_0</ns1:Columns> <ns1:Query>ns0:Query_0</ns1:Query> </ns1:Select></ns0:Root>’);

                    I got error: too many characters in character literal

                    Message_1 is the message I have created against the initial select schema.

                    Even when i tried this:

                    Message_1.Load(‘<root><test></test></root>’);

                    I got same error: too many characters in character literal

                    • #25062

                      Hi,

                      Not Message_1 (you defined not a variable but a message), but this steps:

                      1. Go to Orchestration view window, there you can see a folder called variables. Right click, new variable, give it name lets’ say xDoc – choose type XmlDocument.

                      2. GO to your construct shape, type xDoc.LoadXml(“<Root><YourInstance here><></Root>”); – BTW, you must put the text between ” ” signs and not ‘ ‘ <<< see the difference?

                      3. After that, you choose your message, which is of type of request schema and do like thie:

                      msgRequestToSQL = xDoc;

                      msgRequestToSQL(*) = msgYourSomeMessage(*);

                      And send as request this msgRequestToSQL  message.

                      Here is very helpful tutorial

                      http://geekswithblogs.net/martinabbott/archive/2009/06/03/biztalk-server-2009-and-wcf-sql-adapter.aspx

                       

                       

                      • #25068

                        Yonathan,

                        Thank you very much for your reply. 

                        [quote user="Zx7R"]

                        2. GO to your construct shape, type xDoc.LoadXml(“<Root><YourInstance here><></Root>”); – BTW, you must put the text between ” ” signs and not ‘ ‘ <<< see the difference?

                        [/quote]

                        I typed xDoc.LoadXml(“……”); in the expression of Message Assignment shape within the construct shape.   Is it correct?

                        [quote user="Zx7R"]

                        3. After that, you choose your message, which is of type of request schema and do like thie:

                        [/quote]

                        Is it the message in the Messages folder on Orchestration view?

                        [quote user="7x7R"]

                        msgRequestToSQL = xDoc;

                        msgRequestToSQL(*) = msgYourSomeMessage(*);

                        [/quote]

                        where can I add those lines? 

                        I appreciate your help.

                        Lynn

                      • #25074

                        [quote user="lberan"]I typed xDoc.LoadXml(“……”); in the expression of Message Assignment shape within the construct shape.   Is it correct?[/quote]

                        Yes, that’s right.

                        [quote user="lberan"]Is it the message in the Messages folder on Orchestration view?[/quote]

                         In that folder – you define your messages (every message must be or XmlDocument, or in your case – type of request schema)

                        [quote user="lberan"]where can I add those lines?  [/quote]

                         In a Construct shape. Actually – to build Xml instance you can also in an Expression shape, but for learning purposes that’s OK with Construct shape too.

                        I have built a sample – for you to see how it should look.  I put a rar file, within you will find a solution, a script for table and stored procedure, and a binding.  For running this sample ( if you want to run it – deploy solution, after it deployed – go to administration console, right click on an application – import binding – let the binding file for WCF port to be created – you need two folders in and out on your C:\temp directory). If you have some test DB – create with that scripts table and a stored procedures, and fill table with some data. To run the sample you put the xml “Instance” to “In” folder and in out will appear the data from created table.

                        Download sample http://uploading.com/files/76ma5c8d/SelectTest.rar/

                        If you need some additional help – write here. :))

                         

                      • #25084

                        Yonathan,

                        Your sample is very helpful.  Thank you!

                        Lynn

                      • #25102

                        Yonathan,

                        I posted another question at http://www.biztalkgurus.com/forums/p/14934/28774.aspx#28774 .

                        Could you please take a look?

                        Thanks.

                        Lynn

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