wakanda#3

86
Shibuya, Tokyo Wakanda 勉強会 #3 2013-08-20 presented by

Upload: kmiyako

Post on 11-May-2015

287 views

Category:

Technology


0 download

DESCRIPTION

sample solution and database posted on GitHub: https://github.com/miyako/4d-training-wakanda-3

TRANSCRIPT

Page 1: Wakanda#3

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

agenda

remote procedure call

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

agenda

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

JSON-RPC

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 2: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

agenda

remote procedure call

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

agenda

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

JSON-RPC

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 3: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

agenda

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

JSON-RPC

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 4: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371jahtml

JSON-RPC

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 5: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 6: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

wakanda application framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript+

WAF datasource (widgets)+

WAF dataprovider (REST)

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 7: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 8: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

no framework

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 9: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 10: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 11: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

method echo params [Hello JSON-RPC] id 1

result Hello JSON-RPC error null id 1

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 12: Wakanda#3

Shibuya Tokyo

About-JSON-RPC-Services-in-Wakanda300-306542jahtml

JSON-RPC

remote procedure call

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

JSON-RPChttpenwikipediaorgwikiJSON-RPC

commonJShttpwwwcommonjsorg

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 13: Wakanda#3

Shibuya Tokyo

commonJS

場所 projectFolderModulesmyRPCJS (サブフォルダーでも良い)

構成 1 filemodule n functionsmodule

javascript not just for browsers any more

httpwwwcommonjsorgspecsmodules10

戻り値 必須 (null でも良い)

アクセス権 module毎 function毎

JSON-RPC

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 14: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

regular

function add (a b) return (a + b)

exportsadd = function add (a b) return (a + b)

commonJS

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 15: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

notExposedVarはエクスポートされない

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 16: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

commonJS

require(myRPC)add()

他のサーバーサイドJavaScriptからモジュールを呼び出すとき

var notExposedVar = foo

exportsCONSTANT_1 = hello

exportsadd = function add (a b) return (a + b)

ModulesmyRPCjs

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 17: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 18: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 19: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 20: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 21: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 22: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 23: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 24: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 25: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 26: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 27: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

Set as RPC

ltxml version=10 encoding=UTF-8gtltpermissionsgt ltallow type=module resource=myRPC action=executeFromClientgtltpermissionsgt

projectFolderpermissionswaPerm

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 28: Wakanda#3

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

permission

attribute value remarks

type modulefuntion

resource modulePathmodulePathfuntionName

action executeFromClientpromote promote アクセス権を昇格して実行

groupID group UUID default no authentication

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 29: Wakanda#3

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 30: Wakanda#3

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 31: Wakanda#3

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 32: Wakanda#3

Shibuya Tokyo

Assigning-Group-Permissions200-725897jahtml

projectFolderprojectNamewaSettings

publish

ltxml version=10 encoding=UTF-8gtltsettingsgt ltprojectgt lthttpgt ltservice name=webApp modulePath=serviceswebApp enabled=true autoStart=truegt ltservice name=rpc modulePath=servicesrpc enabled=true autoStart=true proxyPattern=^rpc-proxy publishInClientGlobalNamespace=falsegt ltservice name=dataStore modulePath=servicesdataStore enabled=true autoStart=truegt ltservice name=upload modulePath=servicesupload enabled=true autoStart=truegt ltservice name=Git HTTP Service modulePath=serviceswaf-gitwaf-GitService enabled=truegt ltresourcesgt ltjavaScriptgtltsettingsgt

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 33: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 34: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 35: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 36: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

syntax1

var mathTools = sine function () cos function () atan function ()

var mathTools = mathToolssine= function () mathToolscos = function () mathToolsatan = function ()

syntax2

【参考】

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 37: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 38: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 39: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 40: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

error handling

code message remarks

-32601 Method not found

-32603 Internal error while throw カスタムエラー

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 41: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

button1click = function button1_click (event)

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(emessage)

ecode エラーコードemessage エラーメッセージ

error handling

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 42: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result) catch (e) consolelog(edata)

ecode エラーコードemessage エラーメッセージ

error handling

edata エラーメッセージオブジェクト

button1click = function button1_click (event)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 43: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

ModulesmyRPCjs

exportsadd = function add (a b) if ((alength) ampamp (blength)) return (a + b) else throw new UserException(Arguments cant be empty 1)

function UserException(message code) thismoduleName = myRPC thismessage = message thiscode = code

error handling

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 44: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

synchronous call

try var a = $$(textField1)getValue() var b = $$ (textField2)getValue() var result = myRPCadd(ab) $$(richText1)setValue(result)catch (e) consolelog(emessage)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 45: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 46: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$ (textField1)getValue() $$(textField2)getValue())

Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 47: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 48: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

myRPCaddAsync( function (result) $$(richText1)setValue(result) $$(textField1)getValue() $$(textField2)getValue())

コールバックメソッド(成功時のみ)Async 非同期モードRPCのsuffix

パラメーター(そのまま列挙)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 49: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 50: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 51: Wakanda#3

Shibuya Tokyo

Calling-Methods-from-the-Client-Side300-306631jahtml

button1click = function button1_click (event)

asynchronous call

var result = myRPCaddAsync( onSuccess function (result) $$(richText1)setValue(result) onError function (error) consolelog(edata) params [$$(textField1)getValue() $$(textField2)getValue()] )

パラメーター(配列)コールバックメソッド(成功時失敗時)

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 52: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 53: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 54: Wakanda#3

Shibuya Tokyo

Configuring-CommonJS-Modules-for-RPC300-306585jahtml

namespace

indexwaPageindexhtml

ltmeta name=WAFconfigrpcfile content=rpc-proxymyRPCnamespace=myRPCgt

ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt

any html

デフォルト名前空間 RPCモジュールjsのファイル名

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 55: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 56: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

plainhtml

ltDOCTYPE htmlgtlthtmlgt ltheadgt lttitlegtplainlttitlegt ltmeta http-equiv=Content-Type content=texthtml charset=UTF-8 gt ltscript type=textjavascript src=rpc-proxymyRPCnamespace=myRPCgtltscriptgt ltheadgt ltbodygt lth1gt ltinput type=text id=textInput1 value=Hello gtltinputgt ltinput type=text id=textInput2 value=World gtltinputgt ltbutton onclick=documentgetElementById(textInput3)value = myRPCadd(documentgetElementById(textInput1)value documentgetElementById(textInput2)value)gtmyRPCadd()ltbuttongt ltinput type=text id=textInput3 readOnly=true gtltinputgt lth1gt ltbodygtlthtmlgt

synchronous call

JSON-RPC

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 57: Wakanda#3

Shibuya Tokyo

Using-JSON-RPC-ServicesError-Handling300-306655jahtml

synchronous call

JSON-RPC

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 58: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

HTTP request handler

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 59: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

HTTP request handler

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 60: Wakanda#3

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

client Side JavaScript

no framework

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 61: Wakanda#3

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no JavaScript

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 62: Wakanda#3

Shibuya Tokyo

HTTPHTTP200-803294jahtml

HTTP request handler

browsers server

NoSQL object datastore+

web server+

Server Side JavaScript

HTTP client

no server restart

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 63: Wakanda#3

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

add handler

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 64: Wakanda#3

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

httpwwwicu-projectorguserguideregexphtml

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 65: Wakanda#3

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

ファイル名

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 66: Wakanda#3

Shibuya Tokyo

Global-ApplicationApplicationaddHttpRequestHandler301-636268jahtml

HTTP request handler

addHttpRequestHandler( (i)^demo$ myRequestHandlerjs do_demo )

リクエストURLパターン ICU正規表現

add handler

関数名ファイル名

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 67: Wakanda#3

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 68: Wakanda#3

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 69: Wakanda#3

Shibuya Tokyo

Introduction-to-HTTP-Request-Handlers200-803294jahtml

HTTP request handler

function do_demo(request response) return Hello world

handler function

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 70: Wakanda#3

Shibuya Tokyo

HTTP-Request-HandlersHTTPRequest201-803366jahtml

HTTP request handler

HTTPRequest

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 71: Wakanda#3

Shibuya Tokyo

HTTP-Request-HandlersHTTPResponse201-805902jahtml

HTTP request handler

HTTPResponse

body - String | Image | Blob requestLine - String isSSL - Boolean

contentType - String url - String

method - String rawURL - String parts - MIMEMessage

host - String urlPath - String headers - HTTPRequestHeader

version - String urlQuery - String statusCode - Number

user - String remoteAddress - String remotePort - Number

password - String localAddress - String localPort - Number

allowCache() allowCompression()

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 72: Wakanda#3

Shibuya Tokyo

Executing-Code-on-the-Server300-575371enhtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 73: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

remote procedure call

JSON-RPC HttpRequestHandler Datastore

タイプ サービス リクエストハンドラー クラスメソッド

再起動不要 no yes no

クライアント JavaScript HTTP JavaScript

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 74: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 75: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 76: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 77: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 78: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

scope

client server derived class class

public OK OK OK OK

public on server OK OK OK

protected OK OK

private OK

datastore class method

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 79: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datasource

indexwaPageindexhtml

var result = sourcesmyClassmyMethod()

datastore class method

dataSource名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 80: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

dataprovider

indexwaPageindexhtml

datastore class method

var result =dsMyClassmyMethod()

class名の大文字小文字に注意

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 81: Wakanda#3

Shibuya Tokyo

Using-Datastore-Class-Methods200-878615jahtml

datastore class method

datasourcedataprovider

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 82: Wakanda#3

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 83: Wakanda#3

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

REST

GET http1270018081restMyClassmyMethod

POST http1270018081restMyClassmyMethod

datastore class method

class method名の大文字小文字に注意

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 84: Wakanda#3

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 85: Wakanda#3

Shibuya Tokyo

HTTP-RESTManipulating-DatadatastoreClassmethod303-814342jahtml

datastore class method

REST

GET http1270018081restMyClassmyMethod(abc)

POST http1270018081restMyClassmyMethod

body [abc]

resultabc

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by

Page 86: Wakanda#3

Shibuya Tokyo

Wakanda勉強会 32013-08-20

presented by