首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wakanda RPC客户端

Wakanda RPC客户端
EN

Stack Overflow用户
提问于 2017-05-31 15:06:51
回答 1查看 218关注 0票数 1

我在Wakanda Studio (Angular 4项目)的模块文件夹(后端)中创建了一个JS文件,我启用了RPC并将其添加到permissions.waPerm文件中。

当我签入localhost:8081/rpc-proxy/myRpc/时,我可以看到该方法存在,但我不知道如何访问它的客户端,因为每个关于它的文档都在谈论使用Wakanda studio的Prototyper或GUI设计器,但这两个在当前版本的studio中不再存在。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2017-06-01 04:10:43

在Angular 4或除WAF之外的任何客户端框架中。JSON-PRC服务可以作为应用程序中的外部模块使用HTTP POST进行访问。

根据文档,如果您希望从任何外部页面调用Wakanda RPC方法,则需要向HTML页面添加"script“标记。例如:

代码语言:javascript
复制
<script type="text/javascript" src="/rpc-proxy/myRPC?namespace=myRPC"></script>

WAFmyRPC将在你的angular应用程序中可用。然后,您所要做的就是使用名称空间myRPC (稍作调整)。

以下是我为使其正常工作所做的工作:

  1. 在index.html

中添加脚本

  1. 然后,在你的app.component.ts中声明WAF和myRPC:

declare var myRPC: any; declare var WAF: any;

  • Make调整到WAF对象:

使用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}

  • Call myRPC

'params': [4, 5]})

  • update "proxy.conf.json":包含以下JSON对象:

{ "/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" } } }

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44277928

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档