【发布时间】:2014-08-14 17:27:56
【问题描述】:
按照post,我正在尝试创建一个从 Salesforce 到 Web 服务 (.Net) 的 Apex 标注 - 或者可以接收 POST 的东西。
作为新手我不确定如何捕获从 Salesforce 发送的 Http POST。那就是我在 Salesforce 中有一个 Apex 类,它在 Account 插入时触发:
public class WebServiceCallout {
@future (callout=true)
public static void sendNotification(String name) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://localhost');
req.setMethod('POST');
req.setBody('name='+EncodingUtil.urlEncode(name, 'UTF-8'));
req.setCompressed(true); // otherwise we hit a limit of 32000
try {
res = http.send(req);
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
从逻辑上讲,req.setEndpoint('http://localhost'); 应该替换为我的 IP 和可接受的port。
如果我想了解这个POST,需要在 Visual Studio (.Net) 中构建什么项目?
【问题讨论】:
标签: c# .net salesforce apex callout