jsonRpcService - Remote Service

Exposes a remote service.

Category

Data Access

Syntax

<xe:jsonRpcService attributes>content</xe:jsonRpcService>
Table 1. Essential properties
Property Description
id Defaults to jsonRpcService1, jsonRpcService2, and so on.
pathInfo Identifies the location of the service relative to the XPage.
serviceName Name of a client-side JavaScript service. Overrides pathInfo.
methods Specifies remote methods provided by a service.
Table 2. All properties
Category Properties
basics binding, id, loaded, pathInfo, rendered, rendererType, serviceName, state
other methods
styling disableTheme, themeId

Examples

This example exposes a remote service then uses a button with a client-side script to call a service method and redirect its JSON output to the local file system.
<xe:jsonRpcService id="jsonRpcService1" serviceName="userinfo">
	<xe:this.methods>
		<xe:remoteMethod name="getUserName">
			<xe:this.script><![CDATA[return @UserName()]]&gt;</xe:this.script>
		</xe:remoteMethod>
		<xe:remoteMethod name="add" script="return arg1 + arg2">
			<xe:this.arguments>
				<xe:remoteMethodArg name="arg1"></xe:remoteMethodArg>
				<xe:remoteMethodArg name="arg2"></xe:remoteMethodArg>
			</xe:this.arguments>
		</xe:remoteMethod>
	</xe:this.methods>
</xe:jsonRpcService>
<xp:button value="Display the user" id="button3">
	<xp:eventHandler event="onclick" submit="false">
		<xp:this.script><![CDATA[var deferred = userinfo.getUserName()
deferred.addCallback(function(result) {
	alert(result)
});]]>
		</xp:this.script>
	</xp:eventHandler>
</xp:button>