I am working a salesforce integration project. We are making n number of web service calls to third party services. Now I have to implement a logger , where I need to store the soap request and response in xml format. Most preferable is the same soap request and response xml.

How I can intercept this request and response , in apex problematically ?

Is it the only option left to xml serialize my request and response explicitly ?

  • To do this programmatically you might be able to fish it out of the stack trace by newing up an Exception? Apr 25, 2014 at 10:37
  • @user320 Yes that might work , but as per my research till now , system debugs will not work in Sandboxes , it will only work Dev environment. Apr 25, 2014 at 11:19

2 Answers 2


When you create a Proxy Class from WSDL to call web service it contain all the code.

If you want to debug log in function you can find that function in your proxy class (Generated from WSDL) and intercept all XML. If you want to do it for all request then you need to study the Proxy class and find best place for your interceptor.

  • 1
    +1. Nice. XML dumps of the request and response can only be obtained from the Debug Logs. Reaching into the service class will give you the object dumps but not XML. Apr 25, 2014 at 10:37
  • yes , reaching out to the Service class , I can only have the object dumps , not xml . I already mentioned it in my question "is it the last option to xml serialize my request and response" ? I would like to know how I can get the XML of request and response. Thanks for answering .. Apr 25, 2014 at 11:17
  • I think it's simply not possible :( @SmrutiRanjanTripathy Apr 25, 2014 at 11:41
  • I do not agree with you @SmrutiRanjanTripathy. Here is why developer.salesforce.com/page/Apex_Web_Services_and_Callouts ..... Note the use of outputHttpHeaders_x Apr 25, 2014 at 14:07
  • @AtulRajguru9 Thanx , I Infact followed a similar work around for this. I did intercepted in the proxy class and logged the toString() response (I have overridden the request and response stubs for as Json) of request and response objects into a custom sObject. Aug 12, 2014 at 11:40

The Salesforce solution:

reference is here Inspect outbound SOAP XML requests

  • Thank you for expanding your answer and adding more details, upvoted. Welcome to SFSE!
    – identigral
    Jun 3 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.