1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
<?xml version='1.0'?>
<!--
-
- $Id$
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2012 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:vi="http://www.openlinksw.com/wsdl/"
>
<xsl:output method="text" omit-xml-declaration="yes" indent="yes" />
<xsl:param name="tns" select="/wsdl:definitions/@targetNamespace" />
<xsl:param name="wsdlURI" />
<xsl:template match="/">
-- Automatically generated code
-- imported from WSDL URI: "<xsl:value-of select="$wsdlURI" />"
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="wsdl:definitions">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="wsdl:service">
<xsl:variable name="classname" select="@name" />
<xsl:for-each select="wsdl:port[soap:address]">
<xsl:variable name="binded" select="@binding" />
<xsl:choose>
<xsl:when test="position() = 1">
<xsl:variable name="sname" select="$classname" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="sname" select="concat ($classname,position())" />
</xsl:otherwise>
</xsl:choose>
-- UDT class
drop type "<xsl:value-of select="$sname"/>"
;
create type "<xsl:value-of select="$sname"/>"
as
(
debug int default 0,
url varchar default '<xsl:value-of select="soap:address/@location" />',
ticket varchar default null,
request varchar,
response varchar
)
-- Binding: "<xsl:value-of select="$binded" />"
<xsl:apply-templates select="/wsdl:definitions/wsdl:binding[@name=$binded]" mode="declare" />
method style () returns any
;
-- Methods
<xsl:apply-templates select="/wsdl:definitions/wsdl:binding[@name=$binded]" mode="define" ><xsl:with-param name="class" select="$sname"/></xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="wsdl:binding" mode="declare" >
<xsl:apply-templates select="wsdl:*" mode="declare">
<xsl:with-param name="portname" select="@type" />
<xsl:with-param name="bindname" select="@name" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="wsdl:binding" mode="define" >
<xsl:apply-templates select="wsdl:*" mode="define">
<xsl:with-param name="portname" select="@type" />
<xsl:with-param name="bindname" select="@name" />
<xsl:with-param name="class" select="$class" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="wsdl:operation" mode="declare" >
<xsl:variable name="opname" select="@name" />
<xsl:variable name="oper" select="." />
method "<xsl:value-of select="@name" />"
(
<xsl:apply-templates select="/wsdl:definitions/wsdl:portType[@name = $portname]/wsdl:operation[@name = $opname]" mode="params" >
<xsl:with-param name="bindname" select="$bindname" />
<xsl:with-param name="oper" select="$oper" />
</xsl:apply-templates>
) returns any,
</xsl:template>
<xsl:template match="wsdl:operation" mode="define" >
<xsl:variable name="opname" select="@name" />
<xsl:variable name="oper" select="." />
create method "<xsl:value-of select="@name" />"
(
<xsl:apply-templates select="/wsdl:definitions/wsdl:portType[@name = $portname]/wsdl:operation[@name = $opname]" mode="def_params" >
<xsl:with-param name="bindname" select="$bindname" />
<xsl:with-param name="oper" select="$oper" />
</xsl:apply-templates>
)
<xsl:text>__soap_type '__VOID__' </xsl:text>
for "<xsl:value-of select="$class" />"
{
declare action, namespace, enc varchar;
declare style, form int;
declare _result, _body, xe any;
action := '<xsl:value-of select="soap:operation/@soapAction" />';
<xsl:choose>
<xsl:when test="@elnamespace and @enc = 1">
namespace := '<xsl:value-of select="@elnamespace" />';
form := <xsl:value-of select="boolean (@form = 'qualified')" />;
</xsl:when>
<xsl:when test="wsdl:input/soap:body/@namespace">
namespace := '<xsl:value-of select="wsdl:input/soap:body/@namespace" />';
form := 0;
</xsl:when>
<xsl:otherwise>
namespace := '<xsl:value-of select="@namespace" />';
form := 0;
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="wsdl:input/soap:body/@encodingStyle" >
style := 0;
</xsl:when>
<xsl:when test="@enc = 1" >
style := 5;
</xsl:when>
<xsl:otherwise>
style := 1;
</xsl:otherwise>
</xsl:choose>
if (self.debug)
style := style + 2;
style := style + (form * 16);
_result := DB.DBA.SOAP_CLIENT (
url=>self.url,
operation=>'<xsl:value-of select="@name" />',
soap_action=>action,
target_namespace=>namespace,
parameters=>vector
(
<xsl:apply-templates select="/wsdl:definitions/wsdl:portType[@name=$portname]/wsdl:operation[@name = $opname]" mode="val_params" />
),
headers=>vector
(
<xsl:call-template name="header_params" />
),
style=>style,
ticket=>self.ticket
);
if (self.debug)
{
_body := _result[0];
self.request := _result[1];
self.response := _result[2];
}
else
_body := _result;
xe := xml_cut (xml_tree_doc (_body));
if (xpath_eval ('[ xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" ] //SOAP:Fault', xe, 1) is null)
{
<xsl:apply-templates select="/wsdl:definitions/wsdl:portType[@name=$portname]/wsdl:operation[@name = $opname]" mode="ret_params" /><xsl:text> </xsl:text>;
}
return _result;
}
;
</xsl:template>
<xsl:template match="wsdl:operation" mode="params" >
<xsl:variable name="inmsg" select="wsdl:input/@message"/>
<xsl:variable name="outmsg" select="wsdl:output/@message"/>
<xsl:variable name="inhdr" select="$oper/input/header/@message"/>
<xsl:variable name="outhdr" select="$oper/output/header/@message"/>
<xsl:for-each select="/wsdl:definitions/wsdl:message[@name = $inmsg or @name = $outmsg or @name = $inhdr or @name = $outhdr]/part" >
<xsl:choose>
<xsl:when test="parent::wsdl:message[@name = $inmsg or @name = $inhdr]">
<xsl:variable name="partname" select="''"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="partname" select="@name"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(/wsdl:definitions/wsdl:message[@name = $inmsg or @name = $inhdr]/part[@name=$partname])">
<xsl:text> </xsl:text>"<xsl:value-of select="@name" />" any<xsl:if test="position() < last()">,
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="wsdl:operation" mode="def_params" >
<xsl:variable name="inmsg" select="wsdl:input/@message"/>
<xsl:variable name="outmsg" select="wsdl:output/@message"/>
<xsl:variable name="inhdr" select="$oper/input/header/@message"/>
<xsl:variable name="outhdr" select="$oper/output/header/@message"/>
<xsl:for-each select="/wsdl:definitions/wsdl:message[@name = $inmsg or @name = $outmsg or @name = $inhdr or @name = $outhdr]/part" >
<xsl:variable name="myname" select="@name"/>
<xsl:choose>
<xsl:when test="parent::wsdl:message[@name = $inmsg or @name = $inhdr]">
<xsl:variable name="partname" select="''"/>
<xsl:choose>
<xsl:when test="/wsdl:definitions/wsdl:message[@name = $outmsg or @name = $outhdr]/part[@name=$myname]">
<xsl:variable name="partty" select="'inout'"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="partty" select="'in'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="partname" select="@name"/>
<xsl:variable name="partty" select="'out'"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(/wsdl:definitions/wsdl:message[@name = $inmsg]/part[@name=$partname])">
<xsl:text> </xsl:text><xsl:value-of select="$partty"/><xsl:text> "</xsl:text>
<xsl:value-of select="@name" /><xsl:text>" any </xsl:text>
<xsl:choose>
<xsl:when test="/wsdl:definitions/wsdl:message[@name = $inhdr or @name = $outhdr]/part[@name=$myname]">
<xsl:variable name="ishdr" select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="ishdr" select="false()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="soap_dt">
<xsl:with-param name="ishdr" select="$ishdr"/>
</xsl:call-template>
<xsl:if test="position() < last()">,
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="soap_dt">
<xsl:if test="@type != '' or @element != ''">
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="$ishdr">__soap_header</xsl:when>
<xsl:otherwise>__soap_type</xsl:otherwise>
</xsl:choose>
<xsl:text> '</xsl:text><xsl:call-template name="par_type"/><xsl:text>'</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="header_params">
<xsl:for-each select="wsdl:input/header">
<xsl:variable name="part" select="@part"/>
<xsl:variable name="message" select="@message"/>
<xsl:for-each select="/wsdl:definitions/wsdl:message[@name = $message]/part[@name=$part]">
<xsl:text> </xsl:text>vector('<xsl:value-of select="@name" />', '<xsl:call-template name="par_type"/>'), "<xsl:value-of select="@name" /><xsl:text>"</xsl:text>
</xsl:for-each><xsl:if test="position() < last()">,
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="wsdl:operation" mode="val_params" >
<xsl:variable name="inmsg" select="wsdl:input/@message"/>
<xsl:for-each select="/wsdl:definitions/wsdl:message[@name = $inmsg]/part" >
<xsl:text> </xsl:text>vector('<xsl:value-of select="@name" />', '<xsl:call-template name="par_type"/>'), "<xsl:value-of select="@name" />" <xsl:if test="position() < last()">,
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="wsdl:operation" mode="ret_params" >
<xsl:variable name="msg" select="wsdl:output/@message"/>
<xsl:for-each select="/wsdl:definitions/wsdl:message[@name = $msg]/part" >
<xsl:text> declare temp any; </xsl:text>
<xsl:text> temp:= </xsl:text> xpath_eval ('//<xsl:call-template name="xpf_elm"/>', xe, 1); if (temp is NULL) return NULL;
<xsl:text> </xsl:text>"<xsl:value-of select="@name" />" := xml_cut (temp);
<xsl:if test="@type != '' or @element != ''">
<xsl:text> </xsl:text>"<xsl:value-of select="@name" />" := soap_box_xml_entity_validating ("<xsl:value-of select="@name" />", '<xsl:call-template name="par_type"/>', <xsl:call-template name="type_mode"/>);
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="par_type">
<xsl:choose>
<xsl:when test="@type">
<xsl:value-of select="@type" />
</xsl:when>
<xsl:when test="@element">
<xsl:value-of select="@element" />
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="xpf_elm">
<xsl:choose>
<xsl:when test="@type"><xsl:value-of select="@name" /></xsl:when>
<xsl:when test="@element"><xsl:value-of select="vi:split-name(@element,1)" /></xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="type_mode">
<xsl:choose>
<xsl:when test="@type">0</xsl:when>
<xsl:when test="@element">1</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>
|