4

I like to capture and store XML Request data in custom object before making SOAP api call out for some special purpose, I don't currently see option to get the actual request data in apex, the alternative is manually writing apex code to create soap envelope and store it before making call out, its lot of work i feel. Any suggestions?

Thanks

2

Your options are to extract the CALLOUT_REQUEST from the debug log (Callout category at the Info level) or to make the SOAP request via Apex. The former will be problematic as it needs to occur after the transaction completes. That's fine for debugging, but not so easy for production. Also, the CALLOUT_REQUEST logging isn't generated in every environment.

I've made an alternative version of Wsdl2Apex that generates the required Apex from the WSDL. You can get it for free in the FuseIT SFDC Explorer (Disclosure: This is my current employer).

After selecting the WSDL, change the Select Method Type to "SOAP and HTTP". SOAP and HTTP generation

The resulting Apex class that gets generated will have an addition method with the _Http suffix that uses an HttpRequest and generates the XML required. You could log that XML as required.

SOAP request via HttpRequest

There is also the open source version of Wsdl2Apex. That would take a bit of work, but you could modify the generated Apex to log the request. It would probably be easier to log the request objects that are passed to WebServiceCallout.invoke rather than the XML that results.

1
  • Thanks for the info, I don't find a clean way to solve this issue since it can't be guaranteed. logging stub objects is same effort as construction xml request programmatically, Btw FuseIT explorer is very useful! – realnumber May 19 '15 at 23:45
1

Adding my own best answer, based on some internet research:

You can use an external tool like Runscope as a webservice proxy to automatically forward requests and pass through responses and view the XML SOAP messages. This is not a native solution on SFDC but it does do the job.

https://www.runscope.com/

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.