XML
  Home arrow XML arrow Page 3 - Send Part of an XForms Instance to a Web S...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Send Part of an XForms Instance to a Web Service
By: developerWorks
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2004-11-02

    Table of Contents:
  • Send Part of an XForms Instance to a Web Service
  • Structuring the form
  • Creating the submission
  • Resources

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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

    ...
              </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
          </soapmessage>
         </data>

        </xforms:instance>

        <xforms:submission id="getweather" method="text-xml-post"
         ref="instance('weatherInstance')//soapmessage/*"
         replace="instance"
         action="http://services.xmethods.net:80/soap/servlet/rpcrouter"
        />

     </xforms:model>

    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.

    Summary

    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.

    More XML Articles
    More By developerWorks


     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek