Sign in

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

Register | Forgot password

Recent blogs

RSS - Blogs
December 24, 2008
The year has almost ended...
December 9, 2008
5 Spring pitfalls
December 9, 2008
Like A Version
October 22, 2008
New certification process
October 17, 2008
Search quest [3/3] - improvements

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

noudse | 07-04-2008 13:29

hi,

I do not see the "Generic handler for executing webservice calls" in the class list. Do I need a WCB for this?

/arnoud


 
francoisp | 07-04-2008 16:12

Hi Mark,
Thanks, great training-case I think,
grtz
Francois



markvc | 08-04-2008 09:05

@noudse: The "Generic handler for executing webservice calls" can be made visible by opening the form options, selecting the "Handler definitions" tab and than selecting the handler in the dropdown box. Now, you change the "Rule type" to "Handler", you click "Apply" and it should be visible
This is also reported in GXWM-4635, so it can be fixed for future releases.



noudse | 11-04-2008 08:41

hi,

I have made it working, this is a very nice example
But now I'm trying to really understand what is going on and I wonder why you use the xsl:text in the inputXsl?

/arnoud



markvc | 15-04-2008 11:09

@noudse: Because for some reason WebManager escapes the < and > characters if I do not use xsl:text.


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:

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
© 2008 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.