Topic
  • 3 replies
  • Latest Post - ‏2012-04-23T22:46:43Z by SystemAdmin
SystemAdmin
SystemAdmin
1250 Posts

Pinned topic Building an XML file

‏2009-06-17T20:40:41Z |
I'm quite new to Castiron and this is what I'm trying to accomplish
 I have a Salesforce query object that gets me information from a custom object.
What I need to do is to map the output from the query to XML elements and eventually construct an XML file. How do we accomplish this? Do we need a prebuilt XML template? or does CastIron build this one dynamically?
 Any feedback is much appreciated
Updated on 2012-04-23T22:46:43Z at 2012-04-23T22:46:43Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1250 Posts

    You need a schema and WriteXML

    ‏2009-06-17T22:16:00Z  
    1) First, you need to build or acquire an XSD containing the schema for the object you are mapping to.
    2) Import the schema to the project using the right-click "add document" menu item in the XML Schemas directory of the project.
    3) In the variables tab, use the right-click "Create new variable" menu item and create a variable of the type you imported.
    4) Map from the salesforce.com query output to your variable.
    5) Use WriteXML to serialize your variable.
    6) Use an FTP or HTTP activity to write the data to the target.
    Regards,
    Alan
  • Sathya400
    Sathya400
    13 Posts

    Re: You need a schema and WriteXML

    ‏2012-04-18T02:45:47Z  
    1) First, you need to build or acquire an XSD containing the schema for the object you are mapping to.
    2) Import the schema to the project using the right-click "add document" menu item in the XML Schemas directory of the project.
    3) In the variables tab, use the right-click "Create new variable" menu item and create a variable of the type you imported.
    4) Map from the salesforce.com query output to your variable.
    5) Use WriteXML to serialize your variable.
    6) Use an FTP or HTTP activity to write the data to the target.
    Regards,
    Alan
    I have accounts XML which has header details and multiple <account> node which has account details for each customer(xpath is like this: /accounts/account/). I want to read each <account> node and insert into DB. After one insert success, I want to come back and read next <account> node. I don't want to read the header information again and again How do I do this? Can some one help me on this please. Here is a sample xml that i am talking about.

    <accounts>
    <common header info 1>
    <common header info 2>
    <common header info 3>
    <account>
    .
    .
    .
    </account>
    <account>
    .
    .
    .
    </account>
    <account>
    .
    .
    .
    </account>
    </accounts>

    Can some one help me on this please.

    Thank you in advance.
  • SystemAdmin
    SystemAdmin
    1250 Posts

    Re: You need a schema and WriteXML

    ‏2012-04-23T22:46:43Z  
    • Sathya400
    • ‏2012-04-18T02:45:47Z
    I have accounts XML which has header details and multiple <account> node which has account details for each customer(xpath is like this: /accounts/account/). I want to read each <account> node and insert into DB. After one insert success, I want to come back and read next <account> node. I don't want to read the header information again and again How do I do this? Can some one help me on this please. Here is a sample xml that i am talking about.

    <accounts>
    <common header info 1>
    <common header info 2>
    <common header info 3>
    <account>
    .
    .
    .
    </account>
    <account>
    .
    .
    .
    </account>
    <account>
    .
    .
    .
    </account>
    </accounts>

    Can some one help me on this please.

    Thank you in advance.
    The ReadXML activity reads the instance document in its entirety, so there is no need to read it multiple times. You can supply the XML through a variety of methods: HTTP, Web services, eMail, MQ, database, etc. You must make sure you supply an XSD for the document so that you can parse the input.

    Where possible, you should be looking to use bulk inserts to the database (set the batching flag in the configuration of the Database Insert/Update/Upsert activity), rather than row by row. This will make your orchestration faster and more efficient. If you need to process row by row, use the for-each activity.

    You essentially have two design patterns you can use:
    1) Get data -> ReadXML -> For Each account -> Try -> Map row to the Insert DB activity (use the Catch block to handle any database errors)
    2) Get data -> ReadXML -> Try -> Map from the Account complex type in bulk to the Insert DB activity (use the Catch block to handle any database errors)

    For scenario 2, an error will roll back the entire transaction, so you need to plan to have contingency logic in the catch block to decide how to handle any errors you encounter. The most likely errors will be due to check constraints, primary key errors, foreign key constraints, or data errors.

    Alan Moore, WebSphere Cast Iron ISSW STSM