I have an Apex class ( SalesForce class ) that calls a REST web service.
public class WebServiceCallout
{
@future (callout=true)
public static void sendNotification(String aStr)
{
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://xx.xxx.xxx.xx:41000/TestService/web/test');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(aStr);
try
{
res = http.send(req);
}
catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
The REST web service (C #, WCF) looks like this:
public interface ITestService
{
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/test")]
string Test(string aStr);
}
The method Test()performs primitive operations.
When i started
WebServiceCallout.sendNotification("a test message")
POST receives the web service, but how can I read what was set in the HttpRequest tagreq that was set in sendNotification()the - method req.setBody(aStr);?
That is, should there be a parameter string Test(string aStr);?
Do I need to specify anything else, for example, any configs / attributes in WebInvokeor App.config(for example, binding)?