Send Part of an XForms Instance to a Web Service - Structuring the form
(Page 2 of 4 )
The goal of this project is to create a form that submits a SOAP message and then retrieves the SOAP response and displays the result. To do that, you need to add a submission trigger button and the ability to read the returned data, as shown in Listing 3:
Listing 3. Adding the rest of the form itself
...
</data>
</xforms:instance>
</xforms:model>
<xforms:switch id="switch1">
<xforms:case id="requestGUI">
<xforms:select1 appearance="minimal"
ref="instance('weatherInstance')//zipcode">
<xforms:label>Choose Employee</xforms:label>
<xforms:itemset nodeset="instance('weatherInstance')//emp">
<xforms:label ref="name"/>
<xforms:value ref="zip"/>
</xforms:itemset>
</xforms:select1>
<xforms:trigger style="display:block">
<xforms:label>Get sensor ambient temperature</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:send submission="getweather" />
<xforms:toggle case="responseGUI" />
</xforms:action>
</xforms:trigger>
</xforms:case>
<xforms:case id="responseGUI">
<xforms:output ref="instance('weatherInstance')//return">
<xforms:label>Employee local temperature:</xforms:label>
</xforms:output>
</xforms:case>
</xforms:switch>
</body>
</html>
Here you separate the form into two cases because the instance that provides data for the controls will be different before and after submission. You start with the first case, which includes the employee data control and a trigger button. When the user clicks the trigger, the browser sends the getweather submission (which you'll create next) and changes to the responseGUI case, which will look for data in the new structure. Once in the responseGUI case, the browser displays the temperature, which is in the return element.
Now you just have to create the actual submission.
Visit developerWorks for thousands of developer articles, tutorials, and resources related to open standard technologies, IBM products, and more. See developerWorks.
|
Next: Creating the submission >>
More XML Articles
More By developerWorks