FastTax C# Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
try
{
DOTSFastTaxSoapClient ws = new DOTSFastTaxSoapClient();
BestMatchResponse response = new BestMatchResponse();
response = ws.GetBestMatch(Address.Text, Address2.Text,City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text);
if ((response.Error == null))
{
ProcessValidResponse(response);
}
else
{
ProcessErrorResponse(response.Error);
}
}
catch (Exception er)
{
//Set the Primary and Backup Service References as necessary
try
{
DOTSFastTaxSoapClient wsbackup = new DOTSFastTaxSoapClient();
BestMatchResponse response = new BestMatchResponse();
response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text);
if ((response.Error == null))
{
ProcessValidResponse(response);
}
else
{
ProcessErrorResponse(response.Error);
}
}
catch (Exception ex)
{
resultsLabel.Visible = true;
resultsLabel.Text = ex.Message;
}
}
try { DOTSFastTaxSoapClient ws = new DOTSFastTaxSoapClient(); BestMatchResponse response = new BestMatchResponse(); response = ws.GetBestMatch(Address.Text, Address2.Text,City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text); if ((response.Error == null)) { ProcessValidResponse(response); } else { ProcessErrorResponse(response.Error); } } catch (Exception er) { //Set the Primary and Backup Service References as necessary try { DOTSFastTaxSoapClient wsbackup = new DOTSFastTaxSoapClient(); BestMatchResponse response = new BestMatchResponse(); response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text); if ((response.Error == null)) { ProcessValidResponse(response); } else { ProcessErrorResponse(response.Error); } } catch (Exception ex) { resultsLabel.Visible = true; resultsLabel.Text = ex.Message; } }
try
{
    DOTSFastTaxSoapClient ws = new DOTSFastTaxSoapClient();
    BestMatchResponse response = new BestMatchResponse();
    response = ws.GetBestMatch(Address.Text, Address2.Text,City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text);
    if ((response.Error == null))
    {
        ProcessValidResponse(response);
    }
    else
    {
        ProcessErrorResponse(response.Error);
    }
}
catch (Exception er)
{
    //Set the Primary and Backup Service References as necessary
    try
    {
        DOTSFastTaxSoapClient wsbackup = new DOTSFastTaxSoapClient();
        BestMatchResponse response = new BestMatchResponse();
        response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text);
        if ((response.Error == null))
        {
            ProcessValidResponse(response);
        }
        else
        {
            ProcessErrorResponse(response.Error);
        }
    }
    catch (Exception ex)
    {
        resultsLabel.Visible = true;
        resultsLabel.Text = ex.Message;
    }
}

FastTax Java Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
URL TrialURL = new URL("https://trial.serviceobjects.com/ft/");
URL FailoverURL = new URL("https://trial.serviceobjects.com/ft/");
String Address,Address2,City,State,Zip,TaxType,LicenseKey;
Address = request.getParameter("iAddress");
Address2 = request.getParameter("iAddress2");
City = request.getParameter("iCity");
State = request.getParameter("iState");
Zip = request.getParameter("iZip");
TaxType = request.getParameter("iTaxType");
LicenseKey = request.getParameter("iLicenseKey");
BestMatchResponse FTResponse = null;
DOTSFastTax FTLocator = new DOTSFastTax(TrialURL);
DOTSFastTaxSoap FTClient = FTLocator.getDOTSFastTaxSoap();
try{
FTResponse = FTClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey);
}
catch(Exception r)
{
// Implementing failover logic below as an example.
DOTSFastTax FTLocatorBackup = new DOTSFastTax(FailoverURL);
DOTSFastTaxSoap backupClient = FTLocatorBackup.getDOTSFastTaxSoap();
FTResponse = backupClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey);
}
URL TrialURL = new URL("https://trial.serviceobjects.com/ft/"); URL FailoverURL = new URL("https://trial.serviceobjects.com/ft/"); String Address,Address2,City,State,Zip,TaxType,LicenseKey; Address = request.getParameter("iAddress"); Address2 = request.getParameter("iAddress2"); City = request.getParameter("iCity"); State = request.getParameter("iState"); Zip = request.getParameter("iZip"); TaxType = request.getParameter("iTaxType"); LicenseKey = request.getParameter("iLicenseKey"); BestMatchResponse FTResponse = null; DOTSFastTax FTLocator = new DOTSFastTax(TrialURL); DOTSFastTaxSoap FTClient = FTLocator.getDOTSFastTaxSoap(); try{ FTResponse = FTClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey); } catch(Exception r) { // Implementing failover logic below as an example. DOTSFastTax FTLocatorBackup = new DOTSFastTax(FailoverURL); DOTSFastTaxSoap backupClient = FTLocatorBackup.getDOTSFastTaxSoap(); FTResponse = backupClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey); }
URL TrialURL = new URL("https://trial.serviceobjects.com/ft/");
URL FailoverURL = new URL("https://trial.serviceobjects.com/ft/");
 
String Address,Address2,City,State,Zip,TaxType,LicenseKey;
Address = request.getParameter("iAddress");
Address2 = request.getParameter("iAddress2");
City = request.getParameter("iCity");
State = request.getParameter("iState");
Zip = request.getParameter("iZip");
TaxType = request.getParameter("iTaxType");
LicenseKey = request.getParameter("iLicenseKey");
BestMatchResponse FTResponse = null;
DOTSFastTax FTLocator = new DOTSFastTax(TrialURL);
DOTSFastTaxSoap FTClient = FTLocator.getDOTSFastTaxSoap();
try{
    FTResponse = FTClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey);
}
catch(Exception r)
{
    // Implementing failover logic below as an example.
    DOTSFastTax FTLocatorBackup = new DOTSFastTax(FailoverURL);
    DOTSFastTaxSoap backupClient = FTLocatorBackup.getDOTSFastTaxSoap();
    FTResponse = backupClient.getBestMatch(Address, Address2, City, State, Zip, TaxType, LicenseKey);
}

FastTax PHP Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$Address = trim($Address);
$Address2 = trim($Address2);
$City = trim($City);
$State = trim($State);
$Zip = trim($Zip);
$TaxType = trim($TaxType);
$LicenseKey = trim($LicenseKey);
$params['Address'] = $Address;
$params['Address2'] = $Address2;
$params['City'] = $City;
$params['State'] = $State;
$params['Zip'] = $Zip;
$params['TaxType'] = $TaxType;
$params['LicenseKey'] = $LicenseKey;
try
{
$soapClient = new SoapClient(TrialURL, array( "trace" => 1 ));
$result = $soapClient->GetBestMatch($params)->GetBestMatchResult;
if(isset($result->Error) &&
$result->Error->Number == 4)
{
throw new Exception;
}
}
catch(Exception $e)
{
// Example fail over logic provided below. You should implement a variation which makes use of our backup datacenter
// in the event of a failure at our primary datacenter.
try
{
$soapClient = new SoapClient(FailOverURL, array( "trace" => 1 ));
$result = $soapClient->GetBestMatch($params);
}
catch(Exception $ex)
{//Both soap calls failed
echo "<b> Primary and backup wsdls failed </b>";
return;
}
}
$Address = trim($Address); $Address2 = trim($Address2); $City = trim($City); $State = trim($State); $Zip = trim($Zip); $TaxType = trim($TaxType); $LicenseKey = trim($LicenseKey); $params['Address'] = $Address; $params['Address2'] = $Address2; $params['City'] = $City; $params['State'] = $State; $params['Zip'] = $Zip; $params['TaxType'] = $TaxType; $params['LicenseKey'] = $LicenseKey; try { $soapClient = new SoapClient(TrialURL, array( "trace" => 1 )); $result = $soapClient->GetBestMatch($params)->GetBestMatchResult; if(isset($result->Error) && $result->Error->Number == 4) { throw new Exception; } } catch(Exception $e) { // Example fail over logic provided below. You should implement a variation which makes use of our backup datacenter // in the event of a failure at our primary datacenter. try { $soapClient = new SoapClient(FailOverURL, array( "trace" => 1 )); $result = $soapClient->GetBestMatch($params); } catch(Exception $ex) {//Both soap calls failed echo "<b> Primary and backup wsdls failed </b>"; return; } }
$Address        = trim($Address);
$Address2       = trim($Address2);
$City           = trim($City);
$State          = trim($State);
$Zip            = trim($Zip);
$TaxType        = trim($TaxType);
$LicenseKey     = trim($LicenseKey);
 
$params['Address']      = $Address;
$params['Address2']     = $Address2;
$params['City']         = $City;
$params['State']        = $State;
$params['Zip']          = $Zip;
$params['TaxType']      = $TaxType;
$params['LicenseKey']   = $LicenseKey;
try
{                         
    $soapClient = new SoapClient(TrialURL, array( "trace" => 1 ));
    $result = $soapClient->GetBestMatch($params)->GetBestMatchResult;
     
    if(isset($result->Error) &&
       $result->Error->Number == 4)
        {
            throw new Exception;
        }
}
catch(Exception $e)
{
    
    // Example fail over logic provided below. You should implement a variation which makes use of our backup datacenter
    // in the event of a failure at our primary datacenter.
    try
    {
        $soapClient = new SoapClient(FailOverURL, array( "trace" => 1 ));
        $result = $soapClient->GetBestMatch($params);
         
         
    }
    catch(Exception $ex)
    {//Both soap calls failed
        echo "<b> Primary and backup wsdls failed </b>";
        return;
    }
}

FastTax RoR Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
message = {
"Address" => @request.address,
"Address2" => @request.address2,
"City" => @request.city,
"State" => @request.state,
"Zip" => @request.zipcode,
"TaxType" => @request.taxtype,
"LicenseKey" => @request.licensekey,
}
#Implemented to make the code more readable when accessing the hash
@ftresponse = :get_best_match_response
@ftresult = :get_best_match_result
@ftInfoItems = :tax_info_items
@ftBMtaxInfo = :best_match_tax_info
@fterror = :error
#Set Primary and Backup URLs here as needed
begin
#initializes the soap client. The convert request keys global is necessary to receive a response from the service.
client = Savon.client( wsdl: dotsFTPrimary,
element_form_default: :qualified,
convert_request_keys_to: :camelcase
)
#Calls the operation with given inptus and converts response to a hash.
response = client.call(:get_best_match, message: message).to_hash
#Checks to see what results came back from the service
#@displaydata = response
if (response.nil? || (!response[@ftresponse][@ftresult][@fterror].nil? && response[@ftresponse][@ftresult][@fterror][:number] == "4"))
raise
else
processresults(response)
end
#If an error occurs during the call, this will use backup url and attempt to retrieve data.
rescue StandardError => e
begin
backupclient = Savon.client( wsdl: dotsFTBackup,
element_form_default: :qualified,
convert_request_keys_to: :camelcase
)
#Sets the response to the backclient call to the operation and converts response to a hash.
response = backupclient.call(:get_best_match, message: message).to_hash
processresults(response)
@status = "Backup Call Was Used"
#If backup url failed, this will display the error received from the server
rescue StandardError =>error
@status = error
@displaydata = {"error" => "A Big Error Occured"}
end
end
message = { "Address" => @request.address, "Address2" => @request.address2, "City" => @request.city, "State" => @request.state, "Zip" => @request.zipcode, "TaxType" => @request.taxtype, "LicenseKey" => @request.licensekey, } #Implemented to make the code more readable when accessing the hash @ftresponse = :get_best_match_response @ftresult = :get_best_match_result @ftInfoItems = :tax_info_items @ftBMtaxInfo = :best_match_tax_info @fterror = :error #Set Primary and Backup URLs here as needed dotsFTPrimary = "https://trial.serviceobjects.com/ft/soap.svc?wsdl" dotsFTBackup = "https://trial.serviceobjects.com/ft/soap.svc?wsdl" begin #initializes the soap client. The convert request keys global is necessary to receive a response from the service. client = Savon.client( wsdl: dotsFTPrimary, element_form_default: :qualified, convert_request_keys_to: :camelcase ) #Calls the operation with given inptus and converts response to a hash. response = client.call(:get_best_match, message: message).to_hash #Checks to see what results came back from the service #@displaydata = response if (response.nil? || (!response[@ftresponse][@ftresult][@fterror].nil? && response[@ftresponse][@ftresult][@fterror][:number] == "4")) raise else processresults(response) end #If an error occurs during the call, this will use backup url and attempt to retrieve data. rescue StandardError => e begin backupclient = Savon.client( wsdl: dotsFTBackup, element_form_default: :qualified, convert_request_keys_to: :camelcase ) #Sets the response to the backclient call to the operation and converts response to a hash. response = backupclient.call(:get_best_match, message: message).to_hash processresults(response) @status = "Backup Call Was Used" #If backup url failed, this will display the error received from the server rescue StandardError =>error @status = error @displaydata = {"error" => "A Big Error Occured"} end end
message =   {
            "Address" => @request.address,
            "Address2" => @request.address2,
            "City" => @request.city,
            "State" => @request.state,
            "Zip" => @request.zipcode,
            "TaxType" => @request.taxtype,
            "LicenseKey" => @request.licensekey,
            }
#Implemented to make the code more readable when accessing the hash        
@ftresponse = :get_best_match_response
@ftresult = :get_best_match_result
@ftInfoItems = :tax_info_items
@ftBMtaxInfo = :best_match_tax_info
@fterror = :error
#Set Primary and Backup URLs here as needed
dotsFTPrimary = "https://trial.serviceobjects.com/ft/soap.svc?wsdl"
dotsFTBackup = "https://trial.serviceobjects.com/ft/soap.svc?wsdl"
 
begin
    #initializes the soap client. The convert request keys global is necessary to receive a response from the service.
    client = Savon.client(  wsdl: dotsFTPrimary,
                            element_form_default: :qualified,
                            convert_request_keys_to: :camelcase
                         )
    #Calls the operation with given inptus and converts response to a hash.
    response = client.call(:get_best_match, message: message).to_hash
    #Checks to see what results came back from the service
    #@displaydata = response
    if (response.nil? || (!response[@ftresponse][@ftresult][@fterror].nil? && response[@ftresponse][@ftresult][@fterror][:number] == "4"))
        raise
    else
        processresults(response)
    end        
     
#If an error occurs during the call, this will use backup url and attempt to retrieve data.
rescue StandardError => e
    begin
    backupclient = Savon.client(    wsdl: dotsFTBackup,
                                    element_form_default: :qualified,
                                    convert_request_keys_to: :camelcase
                               )
    #Sets the response to the backclient call to the operation and converts response to a hash.
    response = backupclient.call(:get_best_match, message: message).to_hash
    processresults(response)
    @status = "Backup Call Was Used"
    #If backup url failed, this will display the error received from the server
    rescue StandardError =>error
        @status = error
        @displaydata = {"error" => "A Big Error Occured"}
    end
end

FastTax Python Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#This block of code calls the web service and prints the resulting values to the screen
try:
client = Client(primaryURL)
result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey)
#Loops through either the error result or proper result and displays values to the screen.
if hasattr(result, 'Error') :
if (result.Error.Number == "4"):
raise Exception
else:
for value in result.Error:
Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack()
else:
for value in result:
Label(swin.window, text=str(value[0]) + ": " + str(value[1]) if value[1] else str(value[0]) + " : None").pack()
#Tries the backup URL if the primary URL failed
except:
try:
client = Client(backupURL)
result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey)
if hasattr(result, 'Error') :
for value in result.Error:
Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack()
else:
for value in result:
Label(swin.window, text=str(value[0]) + ": " + str(value[1]) if value[1] else str(value[0]) + " : None").pack()
#If the backup call failed then this will display an error to the screen
except:
Label(swin.window, text='Error').pack()
print ("************************************************************************************************")
print ("************************************************************************************************")
print (result)
return
primaryURL = 'https://trial.serviceobjects.com/ft/soap.svc?wsdl' backupURL = 'https://trial.serviceobjects.com/ft/soap.svc?wsdl' #This block of code calls the web service and prints the resulting values to the screen try: client = Client(primaryURL) result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey) #Loops through either the error result or proper result and displays values to the screen. if hasattr(result, 'Error') : if (result.Error.Number == "4"): raise Exception else: for value in result.Error: Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack() else: for value in result: Label(swin.window, text=str(value[0]) + ": " + str(value[1]) if value[1] else str(value[0]) + " : None").pack() #Tries the backup URL if the primary URL failed except: try: client = Client(backupURL) result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey) if hasattr(result, 'Error') : for value in result.Error: Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack() else: for value in result: Label(swin.window, text=str(value[0]) + ": " + str(value[1]) if value[1] else str(value[0]) + " : None").pack() #If the backup call failed then this will display an error to the screen except: Label(swin.window, text='Error').pack() print ("************************************************************************************************") print ("************************************************************************************************") print (result) return
primaryURL = 'https://trial.serviceobjects.com/ft/soap.svc?wsdl'
backupURL = 'https://trial.serviceobjects.com/ft/soap.svc?wsdl'
#This block of code calls the web service and prints the resulting values to the screen
try:
    client = Client(primaryURL)
    result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey)
    #Loops through either the error result or proper result and displays values to the screen.
    if hasattr(result, 'Error') :
        if (result.Error.Number == "4"):
            raise Exception
        else:
            for value in result.Error:
                Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack()
    else:
        for value in result:
            Label(swin.window, text=str(value[0]) + ":  " + str(value[1]) if value[1] else str(value[0]) + " : None").pack()
#Tries the backup URL if the primary URL failed
except:
    try:
        client = Client(backupURL)
        result = client.service.GetBestMatch(Address=mAddress, Address2=mAddress2, City=mCity, State=mState, Zip=mPostalCode, TaxType=mTaxType, LicenseKey=mLicenseKey)
        if hasattr(result, 'Error') :
            for value in result.Error:
                Label(swin.window, text=str(value[0]) + " : " + str(value[1]) if value[1] else str(value[1])+": None").pack()
        else:
            for value in result:
                Label(swin.window, text=str(value[0]) + ":  " + str(value[1]) if value[1] else str(value[0]) + " : None").pack()
    #If the backup call failed then this will display an error to the screen
    except:
        Label(swin.window, text='Error').pack()
        print ("************************************************************************************************")
        print ("************************************************************************************************")
        print (result)
return

FastTax ColdFusion Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!--Makes Request to web service --->
<cfscript>
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl");
outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#");
if ((Len(outputs.getError()) GT 0) AND outputs.getError().getNumber() == "4")
{
throw Exception;
}
}
}
catch(any Exception){
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl");
outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#");
}
}
catch(any Exception)
{
writeoutput("An Error Has Occured. Please Reload and try again");
}
}
</cfscript>
<!--Makes Request to web service ---> <cfscript> try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl"); outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#"); if ((Len(outputs.getError()) GT 0) AND outputs.getError().getNumber() == "4") { throw Exception; } } } catch(any Exception){ try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl"); outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#"); } } catch(any Exception) { writeoutput("An Error Has Occured. Please Reload and try again"); } } </cfscript>
<!--Makes Request to web service --->
<cfscript>
        try
        {
            if (isDefined("form.Action") AND Action neq "")
            {
                wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl");                            
                outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#");
 
                if ((Len(outputs.getError()) GT 0) AND outputs.getError().getNumber() == "4")
                {
                    throw Exception;
                }
            }
        }
    catch(any Exception){
        try
            {
                if (isDefined("form.Action") AND Action neq "")
                {
                    wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ft/soap.svc?wsdl");                            
                    outputs = wsresponse.GetBestMatch("#Address#", "#Address2#", "#City#", "#State#", "#Zip#", "#TaxType#", "#LicenseKey#");
                     
                }
            }
            catch(any Exception)   
                {
                 writeoutput("An Error Has Occured. Please Reload and try again");              
                }
        }
</cfscript>

FastTax VB Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Try
Dim ws As New FTServiceReference.DOTSFastTaxSoapClient
Dim response As FTServiceReference.BestMatchResponse
response = ws.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response)
Else
ProcessErrorResponse(response.Error)
End If
Catch er As Exception
''Set the Primary and Backup Service References as necessary
Try
Dim wsbackup As New FTServiceReference.DOTSFastTaxSoapClient
Dim response As FTServiceReference.BestMatchResponse
response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response)
Else
ProcessErrorResponse(response.Error)
End If
Catch ex As Exception
resultsLabel.Visible = True
resultsLabel.Text = ex.Message
End Try
End Try
Try Dim ws As New FTServiceReference.DOTSFastTaxSoapClient Dim response As FTServiceReference.BestMatchResponse response = ws.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response) Else ProcessErrorResponse(response.Error) End If Catch er As Exception ''Set the Primary and Backup Service References as necessary Try Dim wsbackup As New FTServiceReference.DOTSFastTaxSoapClient Dim response As FTServiceReference.BestMatchResponse response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response) Else ProcessErrorResponse(response.Error) End If Catch ex As Exception resultsLabel.Visible = True resultsLabel.Text = ex.Message End Try End Try
Try
    Dim ws As New FTServiceReference.DOTSFastTaxSoapClient
    Dim response As FTServiceReference.BestMatchResponse
 
    response = ws.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text)
    If (response.Error Is Nothing) Then
 
        ProcessValidResponse(response)
    Else
        ProcessErrorResponse(response.Error)
    End If
 
 
Catch er As Exception
    ''Set the Primary and Backup Service References as necessary
    Try
        Dim wsbackup As New FTServiceReference.DOTSFastTaxSoapClient
        Dim response As FTServiceReference.BestMatchResponse
 
        response = wsbackup.GetBestMatch(Address.Text, Address2.Text, City.Text, State.Text, Zip.Text, TaxType.Text, LicenseKey.Text)
        If (response.Error Is Nothing) Then
            ProcessValidResponse(response)
        Else
            ProcessErrorResponse(response.Error)
        End If
    Catch ex As Exception
        resultsLabel.Visible = True
        resultsLabel.Text = ex.Message
 
    End Try
End Try

FastTax Apex Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wwwServiceobjectsCom.BestMatchResponse result;
try{
wwwServiceobjectsCom.DOTSFastTaxSoap client = new wwwServiceobjectsCom.DOTSFastTaxSoap();
result = client.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]);
}
catch(Exception ex){
//If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSFastTaxSoap backupClient = new wwwServiceobjectsCom.DOTSFastTaxSoap();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://swsbackup.serviceobjects.com/ft/';
result = backupClient.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]);
}
wwwServiceobjectsCom.BestMatchResponse result; try{ wwwServiceobjectsCom.DOTSFastTaxSoap client = new wwwServiceobjectsCom.DOTSFastTaxSoap(); result = client.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]); } catch(Exception ex){ //If the first request failed try the failover endpoint wwwServiceobjectsCom.DOTSFastTaxSoap backupClient = new wwwServiceobjectsCom.DOTSFastTaxSoap(); //The backup environment will be provided to you upon purchasing a production license key backupClient.endpoint_x = 'https://swsbackup.serviceobjects.com/ft/'; result = backupClient.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]); }
wwwServiceobjectsCom.BestMatchResponse result;
try{
wwwServiceobjectsCom.DOTSFastTaxSoap client = new wwwServiceobjectsCom.DOTSFastTaxSoap();
result = client.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]);
}
catch(Exception ex){
 //If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSFastTaxSoap backupClient = new wwwServiceobjectsCom.DOTSFastTaxSoap();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://swsbackup.serviceobjects.com/ft/';
result = backupClient.GetBestMatch([Address], [Address2], [City], [State], [Zip], [TaxType], [LicenseKey]);
}

FastTax TSQL Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+
'<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+
'<GetBestMatch xmlns="https://www.serviceobjects.com/">'+
'<Address>' + @address + '</Address>'+
'<Address2>' + @address2 + '</Address2>'+
'<City>' + @city + '</City>'+
'<State>' + @state + '</State>'+
'<Zip>' + @zip + '</Zip>'+
'<TaxType>' + @taxtype + '</TaxType>'+
'<LicenseKey>' + @key + '</LicenseKey>'+
'</GetBestMatch>'+
'</s:Body>'+
'</s:Envelope>'
SET @requestLength = LEN(@requestBody)
--If a production key is purchased, this will execute the failover
IF @isLiveKey = 1
BEGIN
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
--Checks the Response for a fatal error or if null.
IF @response IS NULL
BEGIN
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
END
END
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+ '<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+ '<GetBestMatch xmlns="https://www.serviceobjects.com/">'+ '<Address>' + @address + '</Address>'+ '<Address2>' + @address2 + '</Address2>'+ '<City>' + @city + '</City>'+ '<State>' + @state + '</State>'+ '<Zip>' + @zip + '</Zip>'+ '<TaxType>' + @taxtype + '</TaxType>'+ '<LicenseKey>' + @key + '</LicenseKey>'+ '</GetBestMatch>'+ '</s:Body>'+ '</s:Envelope>' SET @requestLength = LEN(@requestBody) --If a production key is purchased, this will execute the failover IF @isLiveKey = 1 BEGIN EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength EXEC sp_OAMethod @obj, 'send', NULL, @requestBody EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT --Checks the Response for a fatal error or if null. IF @response IS NULL BEGIN EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength EXEC sp_OAMethod @obj, 'send', NULL, @requestBody EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT END END
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+
                   '<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+
                   '<GetBestMatch xmlns="https://www.serviceobjects.com/">'+
                   '<Address>' + @address + '</Address>'+
                   '<Address2>' + @address2 + '</Address2>'+
                   '<City>' + @city + '</City>'+
                   '<State>' + @state + '</State>'+
                   '<Zip>' + @zip + '</Zip>'+
                   '<TaxType>' + @taxtype + '</TaxType>'+
                   '<LicenseKey>' + @key + '</LicenseKey>'+
                   '</GetBestMatch>'+
                   '</s:Body>'+
                   '</s:Envelope>'
 
SET @requestLength = LEN(@requestBody)
 
    --If a production key is purchased, this will execute the failover
IF @isLiveKey = 1
BEGIN
    EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
    EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
    EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
    EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
    EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
             
    --Checks the Response for a fatal error or if null.
    IF @response IS NULL
    BEGIN
        EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
        EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/ft/', false
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.serviceobjects.com'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/GetBestMatch"'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
        EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
        EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
        EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
        EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
    END
END