Home arrow XML arrow 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
(Page 1 of 4 )

In previous tips, you've discovered how an XForms form can easily send a Web service request and receive the response, but in all of those cases you were sending the entire instance to the Web service. However, this may not always fit with your plans. For example, the SOAP message may be part of a larger instance document that includes related data. In this tip, you'll learn how to create an XForms form around an instance that includes more than just a SOAP message and then send only the SOAP message on submission. This tip assumes that you are generally familiar with XForms and that you have the FormsPlayer XForms client installed. (See Resources for more information.)

The instance

Start by creating the basic form, including the instance, as shown in Listing 1:

Listing 1. The basic form

    <title>XForms and Web Services</title>
   <object id="FormsPlayer"
     <b>FormsPlayer has not loaded. Please check your installation.</b>
   <?import namespace="xforms" implementation="#FormsPlayer" ?>

   <xforms:model id="WeatherService">

      <xforms:instance id="weatherInstance" >

            <emp id="1">
            <emp id="2">
            <emp id="3">
              <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature"
                 <zipcode xsi:type="xsd:string"></zipcode>




The instance has two basic parts: the employees data and the SOAP message, contained in the soapmessage element. You'll use the employees data to populate the SOAP message before submitting it. To do that, add a select1 control that presents each of the employees as an option, as shown in Listing 2:

Listing 2. Adding a select1 menu


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


This control loops through each of the available emp elements and creates a drop-down menu, as shown in Figure 1.

Figure 1: The basic data control
Send part of an XForms instance to a Web service

Because you've set the select1 element's ref attribute to point to the SOAP message's zipcode element, simply changing the drop-down menu adds the appropriate value to the Web service request.

Before you get to the submission, fill in the rest of the form.

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-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials