Rams --
Glad to hear the service call worked. Here are some next steps.
-- Doug
I'm not sure about the best approach for populating a recordset with the result, without seeing the result. If you can send me the response content, it might make more sense to me. See below
If you have the literal XML string, as in the second example (although I'm not sure why a web service would return that), it can be processed with the Curl XML Document Model (XDM). Just use 'build-xml' to construct the model. To see the structure (useful when developing), you can display in a tree control.
{curl 6.0 applet}
{applet manifest = "manifest.mcurl",
{compiler-directives careful? = true}}
{import * from COM.CURL.WSDK.XML-DOCUMENT-MODEL}
{import * from COM.CURL.WSDK.XML-DISPLAY}
{value
def xml = "YOUR XML"
def xmldoc = {build-xml preserve-whitespace? = false, xml}
{XDMTreeControl open? = true,
xmldoc}
}
You can work directly with the XDM model, using xpath expressions, and binding.
{XDMForm
model = xmldoc.root,
context-path = "Stock",
{Table columns = 2, font-size = 9pt,
{text Symbol},
{TextDisplay {bind value to "Symbol"}},
{text Date},
{TextDisplay {bind value to "Date"}},
{text Last},
{TextDisplay {bind value to "Last"}}
}
In this case, your objective is to populate a recordset, and the XML is just an intermediary. Given the structure of the recordset (presumably available from the service), the standard approach is to iterate over the elements and insert corresponding records.
{define-proc {load-from-xml
rs:RecordSet,
elements:XDMNodeSet
}:void
{with rs.batch-events? = true do
|| process elements
{for element in elements do
|| allocate record
def r = {rs.new-record}
|| expected fields
{for f in rs.fields do
def k = f.name
|| element content
def val = {element.search k}.as-String
|| assign to record (data conversion governed by RecordField domain)
set r[k] = val}
|| insert in recordset
{rs.append r}}
{rs.commit}}
}
There are variations on this theme, depending on the volume of the data, and how much about its structure is known in advance, or from the service, and the application logic to be applied to it.
def rs =
{RecordSet
{RecordFields
{RecordField "Symbol", domain = String},
{RecordField "Name", domain = String},
{RecordField "Date", domain = String},
{RecordField "Time", domain = String},
{RecordField "Open", domain = double},
{RecordField "High", domain = double},
{RecordField "Low", domain = double},
{RecordField "Last", domain = double},
{RecordField "Previous", domain = double},
{RecordField "Change", domain = double},
{RecordField "Percentage", domain = String},
{RecordField "Kita", domain = String},
{RecordField "Nonage", domain = String},
{RecordField "Earns", domain = double},
{RecordField "AP-E", domain = double}}}
def stocks = {xmldoc.search "/Stockpots/Stock"}
{load-from-xml rs, stocks}
{RecordGrid
record-source = rs,
width = 8in}
To capture the response content, there are two possibililities. One way is by setting service.trace-stream, as in the final WSDK dguide example.
The other is to use the HttpMonitor, which is available only in the Curl Pro/IDE version. For that, you can
Start Curl Pro/IDE Trial.
I usually use the HttpMonitor. It can be controlled programmatically, or controlled interactively using the Curl IDE context menu (control right click). Thats usually easier, assuming the request can be triggered from the UI.