Skip to main content

How do I capture SOAP API Requests and Responses?


How do I capture SOAP API Requests and Responses?


In order for Zuora Support to be able to troubleshoot API issues, it is necessary to capture the XML code that is generated by the request and response for debugging purposes. Here you can find how to log raw XML SOAP requests and responses when working in various language/SOAP lib development environments.


#!/usr/bin/perl use strict; 
use warnings; 
use SOAP::Lite +trace => 'all';
my $contact_client = SOAP::Lite->new ( proxy => $SOAP_BASE . 'contact.php', ns => 'urn:ContactService', );
my $token = $contact_client->login($USERNAME, $PASSWORD)->result;


list(, $SOAP_BASE, $USERNAME, $PASSWORD) = $argv; 
$contact_client = new SoapClient($SOAP_BASE . 'contact.php?wsdl', array('trace' => true)); 
$token = $contact_client->login($USERNAME, $PASSWORD); 
$soap_request = $contact_client->__getLastRequest(); 
$soap_response = $contact_client->__getLastResponse(); 
echo "SOAP request:\n$soap_request\n"; 
echo "SOAP response:\n$soap_response\n";


$contact_client = new SoapClient($SOAP_BASE . 'contact.php?wsdl', true); 
$token = $contact_client->call('login', array('user' => $ADV_USERNAME, 'pass' => $ADV_PASSWORD)); 
echo "SOAP request:\n" . $contact_client->request . "\n"; 
echo "SOAP response:\n" . $contact_client->response . "\n";


Compile the stdsoap2.cpp source code with C/C++ compiler option '-DDEBUG' ('/DDEBUG' in MSVC++). Executing your service or client application will log the activities in three files: SENT.log, RECV.log, and TEST.log, containing the messages sent, received, and trace information, respectively.


Save the following code with the name SqlSoapTracer.cs in the same folder that contains the SOAP client project files.

In the Solution Explorer window, perform the following steps:

  1. Select the project by name, right-click and point to Add, and then select Add Existing Item.
  2. In the Add Existing Item dialog box, browse and select the SqlSoapTracer.cs file from the location you saved it to in step 1.
  3. Select Show All Files and expand the Web References node and select the Reference.cs file.

In the Code Editor window, update the Reference.cs file by locating the entry points for your Web methods there. To add SOAP trace support when the Web methods execute in client code, add the following snoopattribute() call in the Reference.cs code directly before the entry point for each Web method you want to trace, as shown in the following lines of code.

[System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:ContactService#login", RequestNamespace="urn:ContactService", ResponseNamespace="urn:ContactService")]
[return: System.Xml.Serialization.SoapElementAttribute("token")]
public string login(string user, string pass, login_options login_options) { object[] results = this.Invoke("login", new object[] { user, pass, login_options}); return ((string)(results[0])); }

This registers a SOAP extension that invokes the SOAP tracing of these Web methods when they are executed.


Save this file as client-config.wsdd in the working directory of your Axis client. Axis will load it automatically. The configuration here tells Axis to save all incoming and outgoing XML into a file named axis.log.

<deployment xmlns="" xmlns:java=""> 
    <handler name="log" type="java:org.apache.axis.handlers.LogHandler"/> 
            <handler type="log"/> 
            <handler type="log"/> 
    <transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/> 


require "soap/wsdlDriver" 
(soap_base, username, password) = ARGV 
contact_client = + 'contact.php?wsdl').create_rpc_driver 
contact_client.wiredump_dev = STDOUT; 
token = contact_client.login(username, password, nil)


import sys 
import SOAPpy 
SOAPpy.Config.debug = 1 
(SOAP_BASE, USERNAME, PASSWORD) = sys.argv[1:4] 
contact_client = SOAPpy.SOAPProxy(SOAP_BASE + 'contact.php') 
token = contact_client.login(USERNAME, PASSWORD)