|
Summary
XSLT framework for writing SOAP endpoints
I decided to call it Kafka since a piece of software without a catchy name isn't as much fun, and I just can't think of any more SOAP puns.
This is an example of using the framework to
build an endpoint in XSL. It's a small framework, but I think that the
hooks can be put in place to keep growing it, and the concept seems sound.
As I said above, I started working with this stuff a little over a week ago, so
if what follows makes no sense or violates some basic tenet of XSL, just send me
an email to let me know, and I'll go back to writing COM code. :)
|
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform version=1.0>
<!-- add.xsl : Kafka SOAP Endpoint Example -->
<!-- Import soap.xsl to use the framework -->
<xsl:import href=..\kafka\soap.xsl/>
<xsl:output method=xml encoding=utf-8 omit-xml-declaration=yes/>
<!-- Define the global variables for the framework -->
<xsl:variable name=Method>Add</xsl:variable>
<xsl:variable name=MethodNS>http://www.topxml.com/</xsl:variable>
<!-- Add : Add two numbers and return the sum -->
<!-- Function Add( A as Double, B as Double ) as Double -->
<xsl:template name=ProcessPayload>
<xsl:param name=Payload/>
<xsl:for-each select=$Payload>
<!-- These lines show you how to look up parameters -->
<xsl:variable name=A select=child::*[local-name() = 'A']/>
<xsl:variable name=B select=child::*[local-name() = 'B']/>
<!-- The WriteParameter template writes out a parameter, and includes -->
<!-- the xsi:type attribute needed for Apache. -->
<xsl:call-template name=WriteParameter>
<xsl:with-param name=p select='Result'/>
<xsl:with-param name=v select=$A + $B/>
<xsl:with-param name=t select='double'/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|
|
soap.xsl
right now, which gets included into the endpoint XSL file like the one above.
soap.xsl has all the templates for verifying the Envelope, version, finding the
Body, looking for the indicated payload, etc. I still need to add Header
munging to it, but that shouldn't be too bad. The soap.xsl file also
contains templates for throwing standard faults and writing response parameters.
The endpoint XSL file just has to do two things: define global variable to help
the framework know what methods you are expecting (this part is optional), and
write a ProcessPayload method that will get called when the methods you indicate
are found in the message. The framework is responsible for making sure
that the specification guidelines are met, you are responsible for coding the
response parameters.
ASP,
JSP, or just execute them locally using XslConnector
or XslTransport.
The ASP file needed just takes the request and transforms it using MSXML.
It's boilerplate and can be used for any endpoint, just change the name of the
XSL file. I've tested the server with the Microsoft SOAP Toolkit,
PocketSOAP, and Apache, and it looks good against all of those clients. My
tests are being done against the endpoints I have built on the server (TimeServer,
Add,
and my favorite, ID);
they all use this framework and illustrate how you can build a couple of
different types of endpoints using it.
http://groups.yahoo.com/group/soapworkshop,
so you can sign up there and talk about SOAP and these tools.
Check
out the Kafka XSL files:
soap.xsl
utils.xsl
Download
the sample application files here:
Add
TimeServer
ID
Valid
|