Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Blogs

  • Bram de Kruijff
  • Ivo Ladage
  • Mark van Cuijk
  • Martin van Mierloo
  • Martijn van Berkum
  • Michel Teunissen
  • Patrick Atoon

Recent blogs

RSS - Blogs
March 9, 2010
State of OSGi in the Java world
March 4, 2010
Reach more people with Google Translate
March 3, 2010
Get My Advice
February 26, 2010
What? Where!?!
February 11, 2010
Split it!

All Blogs...


Baking apple pie at 347

April 7, 2008

Some notable differences between Europe and the US are measuring units: in Europe we don’t use inches (except for television sets and computer screens), we don’t have gallons, we don’t do miles and we definitely do not use Fahrenheit. As part of baking an apple pie last weekend, I had to preheat the oven to 175 degrees Celsius and I was wondering what amount I need on the Fahrenheit scale, so I decided to connect a form to the public CelsiusToFahrenheit WebService to give me the answer.

Calling the WebService

The most important part is to configure a form rule that connects to the WebService, so I create a new rule and name it “Convert temperature (Celsius to Fahrenheit)”. After setting the label to “Handler” and selecting the “Generic handler for executing webservice calls” as the handler class, I am presented some parameters to set:
baseurl http://www.w3schools.com/webservices/tempconvert.asmx
method POST
extraheader Content-Type: application/soap+xml; charset=utf-8
inputXsl (see below)
outputXsl (see below)
sessionkey GX_temperature

inputXsl

<xsl:text disable-output-escaping="yes">
  <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
    <soap12:Body>
      <CelsiusToFahrenheit xmlns="http://tempuri.org/">
        <Celsius></xsl:text>
          <xsl:value-of select="//formpart[@xsltag=\'celsius\']/userentry" />
        <xsl:text disable-output-escaping="yes"></Celsius>
      </CelsiusToFahrenheit>
    </soap12:Body>
  </soap12:Envelope>
</xsl:text>

outputXsl

<xsl:value-of xmlns:tempuri="http://tempuri.org/" select="//tempuri:CelsiusToFahrenheitResult" />

Accessing the result

The result value is stored in the user session beneath the GX_temperature key. The value will therefore be accessible under the <temperature> element when using a personalization, so in the personalize panel I create an XSLT expression of type “select” with the expression “/root/system/temperature”. As tag name I use “wm-temperature”.

Putting it all together

To see it all work, I create a new form model with two steps. The first step has a required text input field with the XSL tag parameter set to “celsius” (which is needed for the inputXsl to find the value of this field). This field has the “Check decimals” validation rule attached, to make sure no garbage is sent to the WebService. The second step also has a text input field, with the presentation set to a read-only variant and the default value set to “”.

So what is 175° C?

Temperature output (Fahrenheit): 347

About the Author

Return to all blogs


Mark is software engineer with a special interest in Security and Digital WebTV. Mark writes about daily engineering with GX WebManager

Read all Marks blog entries

Other blog entries:

March 3, 2010
Get My Advice
February 11, 2010
Split it!
April 22, 2009
What goes in, must come out!
July 29, 2008
WCB Sharing FTW!
June 17, 2008
Found me on LinkedIn?
April 18, 2008
Tosti
March 21, 2008
Short story about not inventing another wheel
March 13, 2008
Files in and files out
February 29, 2008
Big Brother is watching


Share:

del.icio.us
digg
Technorati
Slashdot
Reddit
YahooMyWeb
NewsVine
ekudos
© 2010 GX creative online development B.V.

Disclaimer

This website (GXdeveloperweb.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.