Log SOAP Request and Response XML Strings
Overview
This article describes the zApi.Logger class that you use to inspect the SOAP request and response XML strings in the debug log of Order Builder.
Configure Zuora 360 Version Setting
To use the new global Apex APIs in existing classes, you must set the version number of Zuora 360 to 2.3 or above for the Apex class. This is a feature of Salesforce to prevent backward incompatibility of the package releases. See the Salesforce documentation Managing Version Settings for Apex for more information.
To configure the Zuora 360 package version setting for the class:
- Navigate to user name > Setup > App Setup > Develop > Apex Classes.
- Click Edit for the class that you want to use with the new feature.
- Click the Version Settings tab and set the Version of the Zuora 360 Managed Package to 2.3 or higher.
- Click Save.
zApi.Logger Class
The zApi.logger global class provides logging access to the SOAP request and response XML strings for you to inspect the SOAP request and response when working with Order Builder APIs. It is included in the zApi class via the following zApi properties.
Property | Description |
---|---|
static List<zApi.Logger> zApi.loggers | A list of zApi.Logger instances available in the current request scope. Each logger object contains the logging information of a Zuora API callout. For example, in the same request, if you have made one login() and three create() API callouts, there will be four logger instances in zApi.loggers. |
static zApi.Logger zApi.currentLogger | The logger object containing the Zuora API callout information for the most recent API callout. |
zApi.Logger Properties
The zApi.Logger class has the following properties.
Property | Type | Description |
---|---|---|
apiType | String | The type of the Zuora API callout. The available values are:
|
request | String | The XML SOAP request |
response | String | The XML SOAP response |
requestTime | String | The timestamp when the request was sent, formatted using user's time zone and locale. |
responseTime | String | The timestamp when the response was received, formatted using user's time zone and locale. |
zApi.Logger Methods
The zApi.Logger has one method, toString
, that returns a string representation of the logger object. For example, for a zApi.zCreate()
call, the following code produces the log messages below:
results = zapiInstance.zCreate( populateRatePlans( productId ) ); System.debug( 'logger = ' + Zuora.zApi.currentLogger.toString() );
The code example above returns the following log message:
Zuora API: create [03/05/2012 14:46:11.509 - 03/05/2012 14:46:11.986]: SOAP Request: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:obj="http://object.api.zuora.com/" xmlns:api="http://api.zuora.com/"><env:Header><api:SessionHeader><api:session>uvfWLzWGHweSg35-9eBDGpAJ3ZXBiBaIPnr1vhMV3jwbXMIda3IYY33NTSYCQJ7dNfUbFHJHkScWU1HreScAGrfnbP2wSBzR_u8OhVQ7rXc7MgyHk-3RjMsKb-Y3LFWPhLguiIB36jEmD9SMdwwING9sedO2aI3-rXteCoElpOP2r-bWZMwRyXGozIIL80Do</api:session></api:SessionHeader></env:Header><env:Body><api:create><api:zObjects xsi:type="obj:Product"><obj:EffectiveEndDate>2014-01-01T00:00:00-08:00</obj:EffectiveEndDate><obj:EffectiveStartDate>2010-01-01T00:00:00-08:00</obj:EffectiveStartDate><obj:Name>Mobile Plan 111</obj:Name><obj:SKU>SKU-1336081569111</obj:SKU></api:zObjects></api:create></env:Body></env:Envelope> SOAP Response: <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:createResponse xmlns:ns1="http://api.zuora.com/"><ns1:result><ns1:Id>4028e696370bf97e013714aae05f3ff1</ns1:Id><ns1:Success>true</ns1:Success></ns1:result></ns1:createResponse></soapenv:Body></soapenv:Envelope>
Sample Code
Example 1: Inspect the zApi.currentLogger
that contains the information for the most recent Zuora API callout.
zApi.currentLogger sample code Zuora.zApi zApiInstance = Zuora.zApi.zLogin(); zapiInstance.zCreate( populateRatePlans( productId ) ); System.debug( 'SOAP Request = ' + Zuora.zApi.currentLogger.request ); System.debug( 'SOAP Response = ' + Zuora.zApi.currentLogger.response ); System.debug( 'logger = ' + Zuora.zApi.currentLogger.toString() );
Example 2: Inspect zApi.loggers
that contains the information for all Zuora API callouts in the current request scope.
zApi.loggers sample code for ( Zuora.zApi.Logger logger : Zuora.zApi.loggers ) { System.debug( 'logger = ' + logger.toString() ); }