I get this question a lot so let's record my answer.
How do you populate a drop-down with the returned results of a web service? Let's say the web service returns a repeating XML node (FirstName, LastName).
Do not try to use Dynmaic Data Bindings just yet. They only work the first time you call them as per Adobe's own: http://forms.stefcameron.com/2006/07/29/dynamic-properties/ (Read to the bottom).
You'll have to do it manually with JavaScript. It's real easy though...
Let's say the web service returned results that looked like this:
<Employees><Employee><LastName>White</LastName><FirstName>Brad</FirstName></Employee><Employee><LastName>Sydney</LastName><FirstName>Crosby</FirstName></Employee><Employee><LastName>Joe</LastName><FirstName>Thorton</FirstName></Employee></Employees>
1) Call the web service and drop the results into a hidden text field.
2) Add the string from the textField into the hidden XFA model.
3) Loop through the nodes and call the addItem() method for each value.
Here is the script:
PopulateDropDown.xdpis a sample. Just update the DataConnections.// Create the hidden node.var anynode = xfa.datasets.createNode("dataGroup", "AnyNode");xfa.datasets.nodes.append(anynode);// Load the XML into the new node.xfa.datasets.AnyNode.loadXML(invokeResponse.xmlData.document.rawValue, false, true);// Loop through the node list and populate drop-down.var nodeList = xfa.datasets.AnyNode.Employees.nodes;for(var i = 0; i < nodeList.length; i++) {DropDownList1.addItem(nodeList.item(i).LastName.value);}
Hi Brad,
I want to convert my webservice response into a xmlstring?
Have you got any idea on how to do this?
Thanks,
Ramon
The result that comes back from the webservice is an XML string. The location "invokeResponse.xmlData.document.rawValue" will have your response as a string. In the example above I'm loading the XML string into an XML DOM so that I can process as XML. It's good programming practice not to treat XML as strings.
Did I understand and answer your question correctly?