XML
  Home arrow XML arrow 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  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
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
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Send Part of an XForms Instance to a Web Service


    (Page 1 of 4 )

    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.)

    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


    <html
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    >
      <head>
        <title>XForms and Web Services</title>
      </head>
      <body>
       <object id="FormsPlayer"
            classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
         <b>FormsPlayer has not loaded. Please check your installation.</b>
       </object>
       <?import namespace="xforms" implementation="#FormsPlayer" ?>

       <xforms:model id="WeatherService">

          <xforms:instance id="weatherInstance" >

            <data>
              <employees>
                <emp id="1">
                  <name>Nick</name>
                    <zip>10314</zip>
                </emp>
                <emp id="2">
                    <name>Troy</name>
                    <zip>90210</zip>
                </emp>
                <emp id="3">
                  <name>Bob</name>
                  <zip>34652</zip>
                </emp>
              </employees>
              <soapmessage>
              <SOAP-ENV:Envelope
                 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
                 xmlns:xsd="http://www.w3.org/1999/XMLSchema">
                <SOAP-ENV:Body>
                  <ns1:getTemp xmlns:ns1="urn:xmethods-Temperature"
                     SOAP-ENV:encodingStyle=
                          "http://schemas.xmlsoap.org/soap/encoding/">
                     <zipcode xsi:type="xsd:string"></zipcode>
                  </ns1:getTemp>
                </SOAP-ENV:Body>
              </SOAP-ENV:Envelope>
            </soapmessage>
           </data>

          </xforms:instance>

        </xforms:model>

    </body>
    </html>

    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:model>

          <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>

    </body>
    </html>

    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.

    More XML Articles
    More By developerWorks


     

    XML ARTICLES

    - 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
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway