-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPC.xsp
More file actions
30 lines (29 loc) · 1014 Bytes
/
Copy pathRPC.xsp
File metadata and controls
30 lines (29 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<!-- part 1: the RPC service: Media.Refresh(MediaID) -->
<xe:jsonRpcService id="jsonRpcService1" serviceName="Media">
<xe:this.methods>
<xe:remoteMethod name="Refresh">
<xe:this.arguments>
<xe:remoteMethodArg name="MediaID" type="string"></xe:remoteMethodArg>
</xe:this.arguments>
<xe:this.script><![CDATA[
print("RPC on server" + MediaID);
MediaID="456";
return MediaID+"server";
]]></xe:this.script>
</xe:remoteMethod>
</xe:this.methods>
</xe:jsonRpcService>
<!-- part 2: Calling the RPC from client-side -->
<xp:button value="Go server" id="Action">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[
alert("RPC calling Media from client");
Media.Refresh("ID123").addCallback( function(result){
alert("Back on client"+ result);
});
]]></xp:this.script>
</xp:eventHandler></xp:button>
</xp:view>