- C#
- Java
- PHP
- RoR
- Python
Usage Reports C# Code Snippet
//Add a service to your application https://trial.serviceobjects.com/ur/usagereports.asmx?op=GetDOTSTransactionDetailsByDateRange
DOTSUsageReportsSoapClient Client = new DOTSUsageReportsSoapClient()
Response = Client.GetDOTSTransactionDetailsByDateRange(inputLicenseKey.Text, inputEmailAddress.Text, inputBeginDate.Text, inputEndDate.Text);
if (response.Error != null)
{
//Process Error
}
else
{
//Process Response
}
Usage Reports Java Code Snippet
// Declare Result Object
ReportTransactionDetailUsage Response = null;
ReportDailyUsage usage[] = null;
// Create client through proxy class
DOTSUsageReportsLocator locator = new DOTSUsageReportsLocator();
// Handle request to client
DOTSUsageReportsSoap ur = locator.getDOTSUsageReportsSoap();
// Handle any errors in response
Error error;
Response = soap.getDOTSTransactionDetailsByDateRange(LicenseKey, Email, BeginDate, EndDate);
usage = Response.getDailyUsage();
error = Response.getError();
if(error !=null && error.getNumber() == "3")
{
throw new Exception();
}
//Process Results
if(error == null){
//DOTS Usage Reports Results
}
//Process Errors
else{
//DOTS Usage Reprots Error Results
}
Usage Reports PHP Code Snippets
<?php
// Set these values per web service <as needed>
$wsdlUrl = "https://trial.serviceobjects.com/ur/usagereports.asmx?WSDL";
$params['LicenseKey'] = $LicenseKey;
$params['Email'] = $Email;
$params['BeginDate'] = $BeginDate;
$params['EndDate'] = $EndDate;
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->GetDOTSTransactionDetailsByDateRange ($params);
$result= $response->GetDOTSTransactionDetailsByDateRangeResult
$result= $response->GetDOTSTransGetDOTSTransactionDetailsByDateRangeResult;
if (!isset($result->Error)) {
foreach($result as $k=>$v) {
echo $k . ", " . $v;
}
} else {
foreach($result->Error as $k=>$v) {
echo $k . ", " . $v;
}
}
?>
Usage Reports RoR SOAP Code Snippets
#Formats inputs into a hash to pass to Soap Client
#Hash Keys must be named as they are shown here.
message = {
"LicenseKey" => @request.licensekey,
"Email" => @request.email,
"BeginDate" => @request.begindate,
"EndDate" => @request.enddate
}
#Implemented to make the code more readable when accessing the hash
@urresponse = :get_dots_transaction_details_by_date_range_response
@urresult = :get_dots_transaction_details_by_date_range_result
@urdailyusage = :daily_usage
@urerror = :error
#Set Primary and Backup URLs here as needed
dotsURPrimary = "https://trial.serviceobjects.com/ur/usagereports.asmx?WSDL"
dotsURBackup = "https://trial.serviceobjects.com/ur/usagereports.asmx?WSDL"
begin
#initializes the soap client. The convert request keys global is necessary to receive a response from the service.
client = Savon.client( wsdl: dotsURPrimary)
#Calls the operation with given inptus and converts response to a hash.
response = client.call(:get_dots_transaction_details_by_date_range, message: message).to_hash
#Checks to see what results came back from the service
processresults(response)
#If an error occurs during the call, this will use backup url and attempt to retrieve data.
rescue Savon::Error => e
begin
backupclient = Savon.client(wsdl: dotsURBackup)
#Sets the response to the backclient call to the operation and converts response to a hash.
response = backupclient.call(:get_dots_transaction_details_by_date_range, message: message).to_hash
processresults(response)
#If backup url failed, this will display the error received from the server
rescue Savon::Error =>error
end
end
end
private
def processresults(response)
#Processes Error Response from soap Client
#Processes Valid response from soap client
end
Usage Reports Python Code Snippet
mEmail = Email.get()
if mEmail is None or mEmail == "":
mEmail = " "
mBeginDate = BeginDate.get()
if mBeginDate is None or mBeginDate == "":
mBeginDate = " "
mEndDate = EndDate.get()
if mEndDate is None or mEndDate == "":
mEndDate = " "
mLicenseKey = LicenseKey.get()
if mLicenseKey is None or mLicenseKey == "":
mLicenseKey = " "
#Set Primary and Backup URLs here as needed
primaryURL = 'https://trial.serviceobjects.com/ur/usagereports.asmx?WSDL'
backupURL ='https://trial.serviceobjects.com/ur/usagereports.asmx?WSDL'
#calling web service and print results
try:
client = Client(primaryURL)
result = client.service.GetDOTSTransactionDetailsByDateRange(Email=mEmail, BeginDate=mBeginDate, EndDate=mEndDate, LicenseKey=mLicenseKey)
#Handel response and check for errors
#failover to backupURL
except:
try:
client = Client(backupURL)
result = client.service.GetDOTSTransactionDetailsByDateRange(Email=mEmail, BeginDate=mBeginDate,EndDate=mEndDate, LicenseKey=mLicenseKey)
#Handel response and check for errors
#If the backup call failed then this will display an error to the screen
except:
Label(swin.window, text='Error').pack()
print (result)