Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XMLRPC - Null/Empty Values



I am making a remote call to a local RPC app via AS Studio's XMLRPC method. It works great - real slick. The problem is that when a field in one of my records has no value AS Studio throws an error.

I have isolated this to empty values and it happens when adding the value to the data source for a table view via a repeat function. When I use the append data source command it works fine. So for example my MySQL database which the RPC app acts on has some records that have empty values for certain fields. So a return set might look like...

{
{id:1234, title:"product 1", detail:"red"},
{id:2345, title:"product 2", detail:"green"},
{id:3456, title:"product 3", detail:""}
}

Notice that product 3 has no detail value. The other thing to know is that the above is in AS form and the problem seems to be in the conversion from the XML being received by AS. I know this because I checked the XML from the RPC app and it is sending an empty value for the detail field in such instances - ie.....

<value></value>

So applescript is setting these empty values to the actual RPC app name - "http://xml.theapp.com/xmlrpc_app.lasso"; for example. Actually it seems to be setting it to the app object cause I have to convert the value to a string first and then the table will fill and show the name of the RPC app for the "detail" column. Again, this does not seem to happen when I use the append data source command. Unfortunately I have to iterate through the XML results as I am inserting images in one of the columns - so appending won't work.

The code for calling and updating the data source looks like so.


-- set params set the_params to {id_product:id_product}


-- lasso/RPC.LassoAPP
tell application "http://my-server.local/xml-rpc/ product_images.lasso"
set the_data to call xmlrpc {method name:"fetch_vendor_products", parameters:the_params}
end tell


    -- turn off updating of datasource
    set update views of ds_products_sub to false

-- clear out old datasource contents before turning off update views so any sleected rows get lost
clear_datasource("products_sub")


    -- load the images
    repeat with the_record in the_data
        set the_id to id_product_sub of the_record
        set the_team to the_team of the_record
        set the_detail to the_detail of the_record
        set the_manf_code to manf_code of the_record
        set the_image_path to "/the_path/" & the_id & "_160.jpg"
        set file_exists to check_for_file(the_image_path)

        if file_exists is true then
            set the_image to load image the_image_path
        else
            set the_image to load image "missing_image"
        end if

set the_row to make data row at the end of data rows of ds_products_sub
set contents of data cell "the_id" of the_row to the_id
set contents of data cell "the_team" of the_row to the_team
set contents of data cell "the_detail" of the_row to the_detail as string
set contents of data cell "the_manf_code" of the_row to the_manf_code
set contents of data cell "the_image" of the_row to the_image
set contents of data cell "the_v_image" of the_row to the_image


        -- free the loaded image from memory
        try
            delete the_image
        end try

    end repeat


Thanks in advance

Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.