在 Apex 类中引用远程站点设置 URL? [英] Reference a remote site setting URL in Apex class?

查看:33
本文介绍了在 Apex 类中引用远程站点设置 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 webservice 类,它将在一个托管包中并分发给多个客户端.该类当前有一个变量,其中包含它所访问的服务器的硬编码值.

I have a webservice class that will be in a managed package and distributed to multiple clients. The class currently has a variable with the hardcoded value of the server it's hitting.

问题:每个客户端的服务器都不同,因此硬编码值不起作用.

The problem: the server will be different for each client, so a hardcoded value will not work.

我想既然每个客户端都必须将他们的服务器添加到他们的远程站点设置中,最简单的方法可能是从他们的设置中获取正确的 URL.这可能吗?还是有另一种正确"的方法来实现这一目标?谢谢

I figured since each client will have to add their server to their remote site settings, the easiest way might be to grab the correct URL from their setting. Is this possible? Or is there another "right" way to accomplish this? Thanks

推荐答案

我发现保存配置值的最佳方法是使用 Apex 自定义设置.要以编程方式设置远程站点设置,您可以使用 元数据API.

The best way I've found to save configuration values is to use Apex Custom Settings. To set the Remote Site settings programmatically you could use the Metadata API.

这篇关于在 Apex 类中引用远程站点设置 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆