Home arrow XML arrow Page 3 - 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 - Creating the submission
(Page 3 of 4 )

To submit the form, you have to create a submission element. That submission element specifies not just where the data should go (through the action attribute), but also what data should go and what should happen to the data that comes back. For example, take a look at the simple submission element shown in Listing 4:

Listing 4. A simple submission element

<xforms:submission method="text-xml-post"
    action="http://services.xmethods.net:80/soap/servlet/rpcrouter" />

This element does get the job done, but not as elegantly as you'd like. The XForms client -- or in this case, the browser -- sends the entire instance to the URL specified in the action, and then replaces the entire page with the response, just as it does for a traditional HTML form. However, that's not quite what you want. Instead, you want to send only the contents of the soapmessage element, and when the response comes back replace only the instance, leaving the rest of the form intact. You can specify all of this on the submission element, as shown in Listing 5:

Listing 5. The submission element



    <xforms:submission id="getweather" method="text-xml-post"


The submission element specifies that you only want to send the contents of the soapmessage element, and that when the response comes back, it should only replace the instance and not the entire document.

Note that although you're only submitting a portion of the instance, when the Web service sends back a response, it replaces the entire instance, so this is generally a one-shot deal. To prevent that, you can specify that the returned message doesn't replace anything by using replace="none" -- but that only applies to situations in which it is the submission itself that's important, and not the response.


An XForms form enables you to create an instance that includes a SOAP message, but an instance can also include other data. For example, in this case you've created a form that uses data from elsewhere in the instance to help populate the actual SOAP message. To make this work, you can create a submission element that specifies the portion of the instance you actually want to submit. You can also use the submission element to specify what should happen to the returned data.

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