Integrating API with Classic ASP

Discussion in 'Developers Forum' started by Rob Lucas, Feb 27, 2009.

  1. Rob Lucas New Member

    Hi All,

    I want to integrate the API into class ASP and can't find any valid information on how to do this. For example, what we want to do is dynamically add new customers to KF when they are created on our existing support site written is classic ASP.

    We don't use ASP.NET (So please don't take us down this route :-0)

    Any suggestions on where to start?

    Rob Lucas
  2. DuaneJackson Administrator

  3. Rob Lucas New Member

    Thanks Duane for the prompt reply,

    So the ASP SOAP wrapper (if I am using the correct term) is this _consumewebservice.asp file you have created and then from that you can access the API in your regular ASP, is that my understanding?

    OK, I will give this a try and see how I get on and post back the results.

    Cheers
    Rob Lucas
  4. Rob Lucas New Member

    Hi Again,

    OK, no joy on this. As I previously stated I uploaded your consumewebservice.asp file and then constructed a simple test file (we called customer.asp) that looks up a customer file and all we get is an error in the logfiles stating "Object_required:_'oNode'"

    We havent changed the wrapper file at all, however here is our sample test script "customer.asp".

    <!-- #include file="consumewebservice.asp" -->
    <%
    SOAP_StartRequest "https://secure.kashflow.co.uk/api/service.asmx", "KashFlow", "GetCustomer"
    SOAP_AddParameter "UserName", "xxxxxxxxxxx"
    SOAP_AddParameter "Password", "xxxxxxxxxxx"
    SOAP_AddParameter "Code", "xxxxxxx"
    SOAP_SendRequest

    %>
    <html>
    <head>
    </head>
    <body>
    Name: <%=SOAP_GetResult("Name")%><br />
    Email: <%=SOAP_GetResult("Email")%><br />
    Tel: <%=SOAP_GetResult("Telephone")%><br />
    </body>
    </html>

    This should display the Name, Email and telphone number of the stated customer based on their 'code'.

    What have I missed?

    Rob Lucas
  5. Rob Lucas New Member

    Any ideas anyone, what have I missed???
  6. Rob Lucas New Member

    Hi all,

    OK, I don't know if this makes a difference, but unchecked the IP address restrictions in the API settings within Kashflow and tested the code again and it works.

    I then switched the security setting back on again and it continues to work, so make sure if you get the same problem to check here first to be on the safe side.

    Thanks Duane
  7. Rob Lucas New Member

    In fact guys, I just worked out that if you remove the status line from the code it won't return anything.

    Silly me!
  8. Rob Lucas New Member

    Array Issue

    Hi All,

    I am trying to read in values from Kashflow into an array and finding it a little bit of a challenge. The problem is working with array types in classic ASP which include such objects as:

    • GetCustomers
    • GetQuotesForCustomer
    • GetInvoicesForCustomer

    Here is my psedocode:

    <!--#include file="_consumewebservice.asp"-->
    <%
    SOAP_StartRequest "https://secure.kashflow.co.uk/api/service.asmx", "KashFlow", "GetInvoicesForCustomer"
    SOAP_AddParameter "UserName", "uuuuuuuuuuuu"
    SOAP_AddParameter "Password", "ppppppppppp"
    SOAP_AddParameter "CustID", "cccccc"
    SOAP_SendRequest

    dim custinv
    custinv = SOAP_GetResult("GetInvoicesForCustomerResult")

    for i = x to UBound(custinv)
    response.Write(i)
    Next
    %>

    I understand this is crude but if I could just overcome this initial problem I can work out the rest. Any help would be fantastic.
  9. Rob Lucas New Member

    Objects of type array explained

    OK, I worked on this problem overnight and have come up with a solution for all you classic ASP programmers.

    Using the example of generating a lsit of invoices for a given customer and then printing them out I have come up with this little gem:

    Code:
    <!--#include file="_consumewebservice.asp"--> 
    <%
    Dim custinv 'our data
    Dim strAryINum 'our array
    dim intCount 'just a counter
    Dim i, strinv
    ' 1st capture our invoice data -----------------------------
    SOAP_StartRequest "https://secure.kashflow.co.uk/api/service.asmx", "KashFlow", "GetInvoicesForCustomer"
    SOAP_AddParameter "UserName", "uuuuuuuuuuuuuuuuuuuuuuuuu"
    SOAP_AddParameter "Password", "ppppppppppppp"
    SOAP_AddParameter "CustID", "nnnnnn"
    SOAP_SendRequest
    ' 2nd convert it into an array of invoice numbers -----------------------------
    custinv = SOAP_GetResult("GetInvoicesForCustomerResult") 'our invoice data
    strAryINum = Split(custinv, "Invoice Number : ")'strAryINum is now an array
    intCount = Ubound(strAryINum)
    ' 3rd create a comma delimited list of all invoices -----------------------------
    For i = 1 to Ubound(strAryINum)
    	tempinv = tempinv & cint(left(strAryINum(i),5)) & ","
    	l = len(tempinv)
    	strinv = left(tempinv, l-1)
    	Response.Write i & " = " & cint(left(strAryINum(i),5)) & "<BR>" 'output for verification
    Next
    Response.Write (strinv) & "<BR>" 'output for verification
    ' Finally retrieve the invoices ready for printing -----------------------------
    SOAP_StartRequest "https://secure.kashflow.co.uk/api/service.asmx", "KashFlow", "PrintInvoice"
    SOAP_AddParameter "UserName", "uuuuuuuuuuuuuuuuuuuuuuuuu"
    SOAP_AddParameter "Password", "ppppppppppppp"
    SOAP_AddParameter "InvoiceNumberList", (strinv)
    SOAP_SendRequest
    response.Write "Number of invoices returned = " &(intCount) &"<BR>" 'output for verification
    response.Write "<a href="&(SOAP_GetResult("PrintInvoiceResult")) &">"&"Print Invoice(s)</a>"
    %>
    Simply put, we extract the invoice numbers for a customer, create an array and iterate through and create an invoice list, and finally post it back to Kashflow to get our invoice list results.:)

    Happy Dayz!
  10. Rob Lucas New Member

    Hi There,

    If there are people out there who need to integrate their solutions like Kashflow then please refer them to me, we love moving clients solutions into the cloud instead of working off PC's as it saves them money in the long run and gets them working smarter.

    Do you know of anyone specifically?

Share This Page