So frustrated - ruby help needed

Discussion in 'Developers Forum' started by philsmy, Sep 5, 2010.

  1. philsmy New Member

    We have been trying to integrate with Kashflow for a very long time. We had it working fine for a while, but about 6 months ago something changed somewhere and now our soap calls are only sporadically working.
    It is very frustrating because our calls to create and invoice and register the payment are always working, but our calls to add items to the invoice are rarely working (but do work sometimes!) so a lot of our invoices are showing as 'overpaid' and we are having to maintain all this by hand.
    Our website is written in Ruby on Rails. We are using the standard Soap4r library.

    Kashflow support says the problem is on our end, but, why does it sometimes work and sometimes not? Some calls work, some calls don't. We are using the same library... it just doesn't make sense.

    Does anyone have any positive experiences with kashflow and ruby? Can you help us?
  2. DuaneJackson Administrator

    Hi Phil,

    Are you able to provide some examples of the raw XML that is being generated by you? Examples of calls that work and those that don't would be good.

    Duane
  3. philsmy New Member

    I think I see the issue. We have 2 servers. The problem is in the InsertInvoice call.

    On one server "lines" are getting sent like this:
    <n1:Lines xsi:type="n1:ArrayOfAnyType">
    <n1:anyType xsi:type="n1:InvoiceLine">
    <n1:Quantity xsi:type="xsd:int">1</n1:Quantity>
    <n1:Description xsi:type="xsd:string">3 DVDs at a time, Unlimited</n1:Description>
    <n1:Rate xsi:type="xsd:double">+17.99</n1:Rate>
    <n1:ChargeType xsi:type="xsd:int">970656</n1:ChargeType>
    <n1:VatRate xsi:type="xsd:double">+16</n1:VatRate> <n1:VatAmount xsi:type="xsd:double">+2.8784</n1:VatAmount> <n1:LineID xsi:type="xsd:int">1</n1:LineID>
    </n1:anyType>
    </n1:Lines>

    This is causing your service to reject them.

    On the other server they are sent like this:

    <n1:Lines>
    <n1:anyType>
    <n1:Quantity>1</n1:Quantity>
    <n1:Description>3 DVDs at a time, Unlimited</n1:Description>
    <n1:Rate>+17.99</n1:Rate>
    <n1:ChargeType>970656</n1:ChargeType>
    <n1:VatRate>+16</n1:VatRate>
    <n1:VatAmount>+2.8784</n1:VatAmount>
    <n1:LineID>1</n1:LineID>
    </n1:anyType>
    </n1:Lines>

    Which seems to work fine.
    Now obviously we have an issue with different soap libraries on the 2 servers, but, in my opinion - and looking at the SOAP spec - both of these should be valid...
  4. philsmy New Member

    Actually, here's another example that is more worrying as it says it created the invoice properly, but, it didn't. This invoice ended up with no line items.


    = Request

    POST /api/service.asmx HTTP/1.1
    SOAPAction: "KashFlow/InsertInvoice"
    Content-Type: text/xml; charset=utf-8
    User-Agent: SOAP4R/1.5.9-SNAPSHOT (httpclient.rb/280, ruby 1.8.7 (2009-12-24) [i686-linux])
    Date: Tue, 14 Sep 2010 07:01:46 GMT
    Content-Length: 1781
    Host: secure.kashflow.co.uk

    <?xml version="1.0" encoding="utf-8" ?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Body>
    <n1:InsertInvoice xmlns:n1="KashFlow">
    <n1:UserName xsi:type="xsd:string">xxx</n1:UserName>
    <n1:password xsi:type="xsd:string">xxx</n1:password>
    <n1:Inv xsi:type="n1:Invoice">
    <n1:InvoiceDBID xsi:type="xsd:int">796</n1:InvoiceDBID>
    <n1:InvoiceNumber xsi:type="xsd:int">796</n1:InvoiceNumber>
    <n1:InvoiceDate xsi:type="xsd:date">2010-09-14Z</n1:InvoiceDate>
    <n1:DueDate xsi:type="xsd:date">2010-09-14Z</n1:DueDate>
    <n1:Customer xsi:type="xsd:string">xxx</n1:Customer>
    <n1:CustomerID xsi:type="xsd:int">1216605</n1:CustomerID>
    <n1:paid xsi:type="xsd:int">0</n1:paid>
    <n1:Lines xsi:type="n1:ArrayOfAnyType">
    <n1:anyType xsi:type="n1:InvoiceLine">
    <n1:Quantity xsi:type="xsd:int">1</n1:Quantity>
    <n1:Description xsi:type="xsd:string">2 DVDs at a time, Unlimited</n1:Description>
    <n1:Rate xsi:type="xsd:double">+13.99</n1:Rate>
    <n1:ChargeType xsi:type="xsd:int">970656</n1:ChargeType>
    <n1:VatRate xsi:type="xsd:double">+16</n1:VatRate>
    <n1:VatAmount xsi:type="xsd:double">+2.2384</n1:VatAmount>
    <n1:LineID xsi:type="xsd:int">1</n1:LineID>
    </n1:anyType>
    </n1:Lines>
    <n1:NetAmount xsi:type="xsd:double">+13.99</n1:NetAmount>
    <n1:VATAmount xsi:type="xsd:double">+2.2384</n1:VATAmount>
    <n1:AmountPaid xsi:type="xsd:double">+16.2284</n1:AmountPaid>
    </n1:Inv>
    </n1:InsertInvoice>
    </env:Body>
    </env:Envelope>

    = Response

    HTTP/1.1 200 OK
    Date: Tue, 14 Sep 2010 07:01:47 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    Cache-Control: private, max-age=0
    Content-Type: text/xml; charset=utf-8
    Content-Length: 393

    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><InsertInvoiceResponse xmlns="KashFlow"><InsertInvoiceResult>796</InsertInvoiceResult><Status>OK</Status><StatusDetail /></InsertInvoiceResponse></soap:Body></soap:Envelope>
  5. philsmy New Member

    Any word on this? I don't think our xml is technically wrong...

Share This Page