Inspecting SOAP Callouts Generated From WSDL (WebServiceCallout)
When working with SOAP callouts from within Salesforce, you can’t view the transaction headers and body xml before you invoke the callout. So if the callout fails or an exception occurs, you have very little information to help you solve the problem.
Here's what you need to do to see the contents of your outbound API requests:
Start a free Runscope account (runscope.com) - it's a very useful tool if you do any type of integration.
In Runscope, click on the Captures link on the left menu. At the top of the Captures page, you’ll see a capture URL for the bucket you’re in. Copy that URL.
Use the URL from #2 to create a new Remote Site setting in your org.
Find the interface port class that was created when you converted from a WSDL using wsdl2apex, or the location of the WebServiceCallout.invoke() method in your code.Change the callout endpoint to the URL from #2, and save the class.
Execute your code (anonymous or through UI).
Go to the Runscope Captures page again. A new capture will be shown. Expand the new capture and click on the Request link - that will show you exactly how your transaction is formatted including the header and the SOAP body.