[mashup-dev] Annotating JavaScript to make JavaScript Web services
Deployment easy
Sanjiva Weerawarana
sanjiva at wso2.com
Thu Mar 1 21:40:52 PST 2007
Outstanding! :) So we can use this to annotate Javascript to help generate
WSDL also right?
Cool!
Sanjiva.
Sameera Madushan Jayasoma wrote:
> Hi all,
> Deploying a JavaScript Web services can be as simple as just deploying
> the JavaScript source file without a services.xml. In this instance we
> need a way to declare, what functions in the js source file, should be
> exposed as Web methods. As an example, consider the following js source.
>
> //@WebMethod
> function getCurrencyCode(ipAddress){
> var code = getCountry(ipAddress);
> ....
> return currencyCode;
> }
>
> function getCountry(ipAddress){
> .......
> return countryName;
> }
>
> Only the function getCurrencyCode() is to be exposed as a WebMethod.
>
> I have developed a small patch for Rhino which enable parsing the above
> special comments and mark the function as a WebMethod. Then it is
> possible to modify the JSDeployer written by Thilina in the following
> manner to identify WebMethods.
>
> Object[] ids = engine.getIds();
> for (int i = 0; i < ids.length; i++) {
> String method = (String) ids[i];
> Object object = engine.get(method, engine);
> - if(object instanceof Function){
> + if(object instanceof BaseFunction &&
> ((BaseFunction)object).isWebMethod()){
> AxisOperation axisOp = new InOutAxisOperation(new QName(method));
> axisOp.setMessageReceiver(new JavaScriptReceiver());
> axisOp.setStyle(WSDLConstants.STYLE_DOC);
> axisService.addOperation(axisOp);
> }
>
> }
>
> This patch can be extended to support the required annotations defined
> in JSR-181.
> Sameera
>
> _______________________________________________
> Mashup-dev mailing list
> Mashup-dev at wso2.org
> http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev
>
--
Sanjiva Weerawarana, Ph.D.
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
email: sanjiva at wso2.com; cell: +94 77 787 6880; fax: +1 509 691 2000
"Oxygenating the Web Service Platform."
More information about the Mashup-dev
mailing list