Webservice Macro Example - Processing Namespace

This webservice example calls the Asmx Webservice Example, which will return a result containing a default namespace declaration (in this case http://smartsite.nl/). The response xml will be similar to the following example:

<CelsiusToFahrenheitResponse xmlns="http://smartsite.nl/">
<CelsiusToFahrenheitResult>77</CelsiusToFahrenheitResult>
</CelsiusToFahrenheitResponse>

When using se:xslt as format parameter, you would need to declare and use the (default) namespace of the CelsiusToFahrenheitResponse xml element within the xsl stylesheet to be able to select nodes from this namespace.

In the example below the prefix sm is declared for the http://smartsite.nl/ namespace (on the xsl:stylesheet element). Subsequently this prefix is used within the xpath expressions wherever elements from the http://smartsite.nl/ namespace needs to be selected.

 

Smartsite SXML CopyCode image Copy Code
<se:webservice>
    <se:parameters>
        <se:parameter name="url">http://localhost/TestWebservice.asmx</se:parameter>
        <se:parameter name="methodname">CelsiusToFahrenheit</se:parameter>
        <se:parameter name="methodnamespace">http://smartsite.nl/</se:parameter>
        <se:parameter name="methodarguments">
            <se:collection>
                <se:member name="Celsius">25</se:member>
            </se:collection>
        </se:parameter>
        <se:parameter name="format">
            <se:xslt>
                <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                                            xmlns:sm="http://smartsite.nl/" version="1.0">
                    <xsl:output method="html" indent="yes"/>
                    <xsl:template match="/">
                        <xsl:element name="p">Result: <xsl:apply-templates/></xsl:element>
                    </xsl:template>
                    <xsl:template match="sm:*">    
                        <xsl:value-of select="//sm:CelsiusToFahrenheitResponse"/>
                    </xsl:template>
                </xsl:stylesheet>
            </se:xslt>
        </se:parameter>        
    </se:parameters>
</se:webservice>