Customer Portal

Need URI from XMLWriter to HTTP connector

Comments 5

  • Avatar
    slechtaj
    0
    Comment actions Permalink
    Hi Peter,

    Let me go back to your question. You need to parse the URI out from the XML that you create in XMLWriter. Is that correct? If so, you may use the following way. If generated XML contains the URI/URL, it has to „exist“ before it is sent to XMLWriter. In this case, you can save it to dictionary and load it in reformat (that receives data from XMLWriter and send them to HTTPConnector). Using dictionary, you can easily send the URI/URL into record field without parsing the XML. For you convenience, I attached sample graph. Please let me know, if this helps you.
  • Avatar
    peterskim
    0
    Comment actions Permalink
    Thanks for the response. I am not very familiar with the Dictionary. Is this an object that is shared globally across the execution of the Graph? Or is there a single Dictionary object associated with each record that flows through the Graph?

    I'm asking because each record will have its own URI. For example, a record may have the following key-value pairs:

    Name: John Smith
    Address: 123 Main Street, New York, NY 10001
    Phone (666) 666-6666
    URI: /info/john-smith.xml

    The XMLWriter will construct an XML document like this:

    <record>
    <uri>/info/john-smith.xml</uri>
    <name>John Smith</name>
    <address>123 Main Street, New York, NY 10001</address>
    <phone>(666) 666-6666</phone>
    </record>

    When this gets to the HTTP connector, I need to make an HTTP request to the web service where it parses the URI from the <uri> element and submits the request to the URL:

    http://host:port/documents?uri=/info/john-smith.xml

    with the request body containing the XML.

    If there is a separate dictionary object associated with each record going through the Graph, then this will work perfectly. However, it is meant to be a single globally-scoped key-value pair store shared across the entire execution of the graph, I don't think this will work for me and will need another solution.

    Thanks,
    Peter
  • Avatar
    slechtaj
    0
    Comment actions Permalink
    Hi Peter,

    Now I think I understand what you need. There is one component that may help you. It is component Combine (which is available in CloverETL Designer version 3.3.0). Basically it takes one record from all input records and merge them together (it maps input data to output port). Please see attached example.
  • Avatar
    peterskim
    0
    Comment actions Permalink
    Thanks. I think this might work for me but I'll have to test it. This solution basically assumes that there are no components/logic between the SimpleCopy and Combine components that change the ordering of the records, correct? Since there's no key parameter on the Combine component, it seems to assume that you've designed the Graph such that the two input records are guaranteed to be related, without requiring a key definition.

    This seems slightly "hacky" to me. I think it would be a great enhancement to be able to have the XMLWriter pass out more than one field through its output port, so that this use case is supported in a more intuitive manner.

    Thank you very much for your help and I will respond back to this thread if this doesn't work for some reason.


    Peter
  • Avatar
    slechtaj
    0
    Comment actions Permalink
    Hi Peter,

    Your assumption is correct. However, for the use case you described above, this would be correct design. Data are sent from DataGenerator to SimpleCopy that sends these records to all output ports in the same order. XMLWriter does not change the order of incoming records, therefore these records (formatted as XML) are sent to Combine in the same order as they were sent from DataGenerator/SimpleCopy. On the other hand, in order to make the design clear, you should attempt to put as little components in between SimpleCopy and Combine as possible.

Please sign in to leave a comment.