qbwc / qbxml

QBXML Parser and Validation Tool
MIT License
27 stars 41 forks source link

XMLAttributes are appended as a node #1

Closed stevenmurry closed 11 years ago

stevenmurry commented 11 years ago

Hello.

I'm using this gem for a current project, and have set it up to use through the ApplicationGateway for Quickbooks Online. Due to that, I have modified the gem slightly to change the qbxml version to 6.0 instead of 7.0. I doubt this has anything to do with my real issue, but I thought it could be worth noting.

I'm trying to post a test transaction, and when I pass a hash through the qbxml gem and submit it to Quickbooks online I get this error:

"SAX parser encountered an error parsing request file. Exception from other package: >org.xml.sax.SAXParseException: Attribute "onError" is required and must be specified for >element type "QBXMLMsgsRq". "

This is the hash I'm passing into the gem:

testhash = {:qbxml =>
                {
                  :signon_msgs_rq =>
                     {:signon_ticket_rq =>
                          {:client_date_time => Time.now,
                           :session_ticket => 'xxxxxxxxxxxxxx',
                           :language => 'English',
                           :app_id => 'xxxxxxxxx',
                           :app_ver => '1'}
                     },
                  :qbxml_msgs_rq =>
                     {:xml_attributes =>
                          {:onError => 'stopOnError'},
                      :customer_add_rq =>
                          {:customer_add =>
                               {:name => 'Test Customer Company',
                                :first_name => 'Test',
                                :last_name => 'Customer',
                                :bill_address =>
                                    {:addr1 => 'Business Name',
                                     :addr2 => 'Contact Name',
                                     :addr3 => '123 This St',
                                     :city => 'Cincinnati',
                                     :state => 'OH',
                                     :postal_code => '45202',
                                     :country => 'US'}
                               }
                          }
                     }
                }

}

The XML that is returned from this is:

<?qbxml version="6.0"?> 
<QBXML>   
    <SignonMsgsRq>     
        <SignonTicketRq>       
            <ClientDateTime>2013-04-30 11:06:33 -0400</ClientDateTime>
            <SessionTicket>xxxxxxxxxx</SessionTicket>
            <Language>English</Language>
            <AppID>xxxxxxxxx</AppID>
            <AppVer>1</AppVer>
        </SignonTicketRq>
    </SignonMsgsRq>
    <QBXMLMsgsRq>
        <XmlAttributes>
            <OnError>continueOnError</OnError>
        </XmlAttributes>
        <CustomerAddRq>
            <CustomerAdd>
                <Name>Test Customer Company</Name>
                <FirstName>Test</FirstName> 
                <LastName>Customer</LastName>
                <BillAddress>
                    <Addr1>Business Name</Addr1>
                    <Addr2>Contact Name</Addr2>
                    <Addr3>123 This St</Addr3>
                    <City>Cincinnati</City>
                    <State>OH</State>
                    <PostalCode>45202</PostalCode>
                    <Country>US</Country>
                </BillAddress>
            </CustomerAdd>
        </CustomerAddRq>
    </QBXMLMsgsRq> 
</QBXML> 

So the problem is that the xml_attributes hash is being processed as a node rather than as attributes. Is there something that I'm doing wrong?

Cheers!

skryl commented 11 years ago

Looks like there was an issue with symbolized keys, should be fixed in the latest push. Thanks.

stevenmurry commented 11 years ago

Nailed it.

Thanks, really appreciate this gem, it's a huge help!

skryl commented 11 years ago

Sure thing. Let me know if you run into any other issues. I didn't test it much in the field other than what I was using it for.

Alex Skryl | skryl.org (http://skryl.org)

On Tuesday, April 30, 2013 at 1:14 PM, Steven Murry wrote:

Nailed it. Thanks, really appreciate this gem, it's a huge help!

— Reply to this email directly or view it on GitHub (https://github.com/skryl/qbxml/issues/1#issuecomment-17244644).