Dashboard > WSO2 Mashup Server > Home > Javascript Web Service Annotations
  WSO2 Mashup Server Log in | Register   View a printable version of the current page.  
  Javascript Web Service Annotations
Added by Thilina Gunarathne , last edited by Thilina Gunarathne on Jul 05, 2007  (view change)
Labels: 
(None)

The Mashup Server exposes many Web service artifacts automatically, such as ?wsdl2/?wsdl, ?xsd, ?stub, ?tryit, ?doc.  These artifacts are generated from information in the javascript file implementing the Web service.  Annotations within the file can improve the quality of the artifacts.  All annotations are provided through properties on the Javascript Global and Function Objects.

1.0 Annotations

Annotations can be provided through annotating the functions within Javascript as follows:

//service level annotations
this.targetNamespace = "http://wso2.org/Mashup";
this.schemaTargetNamespace = "http://wso2.org/schema";
this.serviceName = reverse;
this.documentation = <p>Simple string or html markup</p>;
this.scope= "request";

//operation level annotations
reverse.visible = true;
reverse.safe = true;
reverse.operationName = "swap";
reverse.inputTypes = {
  "first" : "string",
  "last" : "string"
}
reverse.outputType = "anyType";
reverse.documentation = <p>Simple string or html markup (xml node, xml nodelist)</p>;

function reverse(first, last) {
  return (<result>{last + first}</result>);
}

1.1 Service Level Annotations

The following optional properties can be applied to the Global object (referred to as "this" outside any function body): 

.targetNamespace(string)

Defines a targetNamespace for the service. If none is supplied, a default one will be provided.

.schemaTargetNamespace(string)

Defines a targetNamespace for the schema of the service. If none is supplied, a default one will be provided.

.serviceName(string);

The service name by which to expose this script as a service.  If absent (empty), the filename is used. This needs to be a single word conformant to the xs:NCName datatype.

.documentation(string | xml | xml node list);

Human-readable documentation for the service.  XML and XML node lists are assumed to be well-formed HTML (no namespace) or XHTML (with XHTML namespace).

.scope(string);

Defines the session object scope for the service. Supported values are "request", "transportsession" and "application". See [Session Host Object] for more details.

1.2 Operation Level Annotations

The following optional properties can be applied to a top-level Function Object.

.visible(boolean)

Whether this function appears as an operation in the WSDL.  Defaults to True. (Private seems to be reserved properties in Rhino.)

.safe (boolean)

Whether this function is nominally idempotent.  Maps to the wsdlx:safe annotation.  Defaults to False.

.operationName (string)

The localName by which to expose this function in the WSDL.  If absent (empty), the function name is used in the WSDL. This needs to be a single word conforming to the xs:NCName data type.

.inputTypes (object) (Optional) A list of parameter names for the function, paired with the name of an XML Schema built-in data type to expose in the WSDL.  Local names for types are assumed to come from the XML Schema built-in namespace.  Refer to [?wsdl2] section for details. (Custom XML Schema types are not supported in version 0.1.)

.outputType (object)

The type of the return object.  The value must be the local name of a built-in XML Schema datatype.  Refer to [?wsdl2] section for details. (Custom XML Schema types are not supported in version 0.1.)

.documentation(string | xml | xml node list);

Human-readable documentation for the operation.  XML and XML node lists are assumed to be well-formed HTML(no namespace).

2.0 Schema Mappings

The following section defines the mapping between annotations in the js and XML data types. 

Annotation Data Type
anyType xs:anyType
anyURI
xs:anyURI
base64Binary
xs:base64Binary
boolean
xs:boolean
byte
xs:byte
date
xs:date
dateTime
xs:dateTime
gday
xs:gday
decimal
xs:decimal
double
xs:double
duration
xs:duration
float
xs:float
hexBinary
xs:hexBinary
int
xs:int
integer
xs:integer
long
xs:long
gMonth
xs:gMonth
gMonthDay
xs:gMonthDay
negativeInteger
xs:negativeInteger
nonNegativeInteger xs:nonNegativeInteger
nonPositiveInteger
xs:nonPositiveInteger
positiveInteger
xs:positiveInteger
short
xs:short
string
xs:string
time
xs:time
unsignedByte
xs:unsignedByte
unsignedInt
xs:unsignedInt
unsignedLong
xs:unsignedLong
unsignedShort
xs:unsignedShort
gYear
xs:gYear
gYearMonth
xs:gYearMonth

3.0 Related Resources

Powered by a free Atlassian Confluence Open Source Project License granted to WSO2 Inc.. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators