[wsf-c-dev] [PHP] annotations
Paul Fremantle
paul at wso2.com
Tue Mar 13 06:16:09 PDT 2007
I'm looking at this set of discussion and wondering if we have taken the
wrong approach in doing annotations in PHP. We are using doc comments,
and maybe we've drunk the Java Kool Aid?
Paul
-------- Original Message --------
Subject: RE: [mashup-dev] Annotating JavaScript to make JavaScript
Webservices Deployment easy
Date: Tue, 6 Mar 2007 14:04:02 -0800
From: Jonathan Marsh <jonathan at wso2.com>
To: 'James Clark' <james at wso2.com>, 'Sameera Madushan Jayasoma'
<sameera at wso2.com>
CC: mashup-dev at wso2.org
References: <45E7B46F.30904 at wso2.com>
<1173080935.6439.14.camel at tamarind.home.jclark.com>
This is a great idea! I've been struggling against the annotations in
comments, and this gives us an interesting way forward.
I played with this idea some and put a small prototype up at [1].
The prototype is an HTML page containing E4X that imports a JS file
(JSService.js in this case) and generates a WSDL by accessing the metadata
properties and using a WSDL 2.0 template. I made up a few annotations to
test it:
function echoJSON(param){
return param.toSource()
}
echoJSON.private = true; // don't expose this function as an operation
function echo(param1, param2){
return new XML(param);
}
echo.XSDtypes = { // XML schema types of the parameters
param1 : "anyType",
param2 : "string",
out : "anyType" // optional "out" parameter to indicates return type
}
echo.safe = true; // this operation is safe
A few observations:
1) It's a little unnatural to specify the metadata after the function, but
in fact you can specify if before the function and it still works. Kinda
surprising, but that's dynamic languages for ya!
2) Within Javascript there is limited ability to discover all the
information necessary to generate a useful WSDL. In the prototype I just
set a few global variables specific to the .js file we're consuming. These
include:
a) The list of functions available to expose. Javascript doesn't seem to
have a way to find what functions are defined from within the language.
This shouldn't be a problem from within Rhino though.
b) The name of the file/service (used for generating all the necessary
names). This also should be available from within Rhino.
c) An endpoint address. This should be available from Rhino via Axis2 as
well.
d) Binding details. I continue to envision these details being picked up
from a config file with useful defaults and merged into the WSDL. In fact
maybe the config file is simply a <wsdl:binding> element (or elements).
3) One artifact not necessarily available within Rhino is a base
targetNamespace, from which WSDL and Schema targetNamespaces can be
generated. This might be something one can set in the config file, but
seems more like an authoring-centric item. Perhaps we should use a
conventionally-named global variable defined within the .js to generate the
targetNamespaces.
(For some reason, clicking on the GenerateHTML page from [1] doesn't open as
an HTML page in Firefox - guess you have to download the two files to test
it out. I copied and pasted the output to a file [2] for your easy
inspection.)
Your thoughts welcome!
[1] http://wso2.org/repos/wso2/people/jonathan/E4X2WSDL/
[2] http://wso2.org/repos/wso2/people/jonathan/E4X2WSDL/JSService.wsdl
Jonathan Marsh - http://www.wso2.com - http://auburnmarshes.spaces.live.com
> -----Original Message-----
> From: mashup-dev-bounces at wso2.org [mailto:mashup-dev-bounces at wso2.org] On
> Behalf Of James Clark
> Sent: Sunday, March 04, 2007 11:49 PM
> To: Sameera Madushan Jayasoma
> Cc: mashup-dev at wso2.org
> Subject: Re: [mashup-dev] Annotating JavaScript to make JavaScript
> Webservices Deployment easy
>
> On Fri, 2007-03-02 at 10:51 +0530, Sameera Madushan Jayasoma wrote:
> > As an example, consider the following js source.
> >
> > //@WebMethod
> > function getCurrencyCode(ipAddress){
> > var code = getCountry(ipAddress);
> > ....
> > return currencyCode;
> > }
>
> Arghhhh! You've been drinking the Java Kool-Aid for too long. Try this
> instead:
>
> function getCurrencyCode(ipAddress){
> var code = getCountry(ipAddress);
> ....
> return currencyCode;
> }
>
> getCurrencyCode.isWebMethod = true
>
> JavaScript already defines a number of properties for Function objects
> automatically, e.g. length for the number of arguments, so this is quite
> natural. Using this approach, you can allow the user to easily specify
> any other metadata you need.
>
> James
>
>
>
>
>
>
>
> _______________________________________________
> Mashup-dev mailing list
> Mashup-dev at wso2.org
> http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
_______________________________________________
Mashup-dev mailing list
Mashup-dev at wso2.org
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
--
Paul Fremantle
VP/Technology and Partnerships, WSO2
OASIS WS-RX TC Co-chair
http://bloglines.com/blog/paulfremantle
paul at wso2.com
(646) 290 8050
"Oxygenating the Web Service Platform", www.wso2.com
More information about the Wsf-c-dev
mailing list