Home arrow XML arrow Page 2 - Send Part of an XForms Instance to a Web Service

Send Part of an XForms Instance to a Web Service

Include your SOAP request within a general instance document: This intermediate level article by Nicholas Chase explains how an XForms form is handy as a Web service client because it enables you to easily send and receive an XML document, but what if you don't necessarily want to send the entire data instance? This tip explains how you can build an instance that includes a SOAP message along with other data, and then send only the SOAP message on submission. (This article originally appeared on IBM developerWorks, 13 Aug 2004, at http://www.ibm.com/developerWorks.)

Author Info:
By: developerWorks
Rating: 4 stars4 stars4 stars4 stars4 stars / 9
November 02, 2004
  1. · Send Part of an XForms Instance to a Web Service
  2. · Structuring the form
  3. · Creating the submission
  4. · Resources

print this article

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




<xforms:switch id="switch1">
  <xforms:case id="requestGUI">

      <xforms:select1 appearance="minimal"
         <xforms:label>Choose Employee</xforms:label>
         <xforms:itemset nodeset="instance('weatherInstance')//emp">
           <xforms:label ref="name"/>
           <xforms:value ref="zip"/>

      <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:case id="responseGUI">

       <xforms:output ref="instance('weatherInstance')//return">
          <xforms:label>Employee local temperature:</xforms:label>



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.

IBM developerWorksVisit developerWorks for thousands of developer articles, tutorials, and resources related to open standard technologies, IBM products, and more. See developerWorks.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials