我在Wakanda Studio (Angular 4项目)的模块文件夹(后端)中创建了一个JS文件,我启用了RPC并将其添加到permissions.waPerm文件中。
当我签入localhost:8081/rpc-proxy/myRpc/时,我可以看到该方法存在,但我不知道如何访问它的客户端,因为每个关于它的文档都在谈论使用Wakanda studio的Prototyper或GUI设计器,但这两个在当前版本的studio中不再存在。
有什么想法吗?
发布于 2017-06-01 04:10:43
在Angular 4或除WAF之外的任何客户端框架中。JSON-PRC服务可以作为应用程序中的外部模块使用HTTP POST进行访问。
根据文档,如果您希望从任何外部页面调用Wakanda RPC方法,则需要向HTML页面添加"script“标记。例如:
<script type="text/javascript" src="/rpc-proxy/myRPC?namespace=myRPC"></script>WAF和myRPC将在你的angular应用程序中可用。然后,您所要做的就是使用名称空间myRPC (稍作调整)。
以下是我为使其正常工作所做的工作:
中添加脚本
declare var myRPC: any; declare var WAF: any;
使用documented APImyRPC.isEmptyAsync({ 'onSuccess': function(result) { console.log(result); }, 'onError': function(error){ console.log('An error occured: '+error); },的WAF.core = {restConnect:{baseURL : "${window.location.origin}"}}; WAF.config = {enableFilePackage:true}
'params': [4, 5]})
{ "/rest/*": { "target": "http://127.0.0.1:8081", "secure": false, "ws": true, "headers": { "host": "127.0.0.1:8081", "origin": "http://127.0.0.1:8081" } }, "/rpc-proxy/*": { "target": "http://127.0.0.1:8081", "secure": false, "ws": true, "headers": { "host": "127.0.0.1:8081", "origin": "http://127.0.0.1:8081" } }, "/rpc/*": { "target": "http://127.0.0.1:8081", "secure": false, "ws": true, "headers": { "host": "127.0.0.1:8081", "origin": "http://127.0.0.1:8081" } } }
希望这能有所帮助。
https://stackoverflow.com/questions/44277928
复制相似问题