0
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(EndpointUrl);
req.setMethod('POST');
req.setBody(xmlstring);
req.setHeader('Content-Type', 'application/xml'); 
HttpResponse res = http.send(req);
string xmlresponse=res.getBody();

I am getting data and it is working fine but i need to send success message and some data to same url as i received data from server.

Is there any way to do that

Please help me out.

2
  • Same way like you're doing the first call I believe. Another post request after you receive the data? Jun 19, 2014 at 7:10
  • Yes after receiving the data i need to send response data as i received their data.
    – Sunny
    Jun 19, 2014 at 8:29

1 Answer 1

1

You can do that by sending response to the application making the call to your web service. Here is an example:

    RestResponse res = RestContext.response;
    res.statusCode = 200; //Signifies OK
    jsonResponse = '{"response": {"Data": "Value", "Data": "Value"}}';
    res.responseBody = blob.valueOf(jsonResponse);
    return;

Add the above code after the point when you have received and saved the data incoming from the web service.

Let me know if it works for you.

Happy Coding!!

4
  • I placed the code and make it as return type string for that method, and i need to send xml format like xml format , can u help me.... The response is coming in "data we sent" format in their response
    – Sunny
    Jun 19, 2014 at 9:10
  • You need not set the return type to string , the above code will send the response in JSON. I'm sorry I did not get the the issue above can you elaborate a little. Jun 19, 2014 at 9:21
  • Actually when we sending the response in the other side we are getting the response data enclosed with "" symbols.
    – Sunny
    Jun 19, 2014 at 9:37
  • That's right, it is in JSON. If let's say the other system is .net based you can use inbuilt classes to parse the above response in to a Name = value formal like normal objects and data types. What you now need is to parse the JSON response in the desired object type. Jun 19, 2014 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .