AX 2009 X++ CLR Error while calling OrderService.GetOrderList

350 views
Skip to first unread message

Jeff Zhou

unread,
Oct 8, 2012, 7:05:47 PM10/8/12
to ca...@googlegroups.com
Hi,

Thanks in advance for any insights and/or helps. ^^;

I am programming in MS Dynamics AX 2009, with X++ language.
below is the X++ codes, I keep getting this error. "CLR object cannot be marshaled to Microsoft Dynamics anytype.". After investigation, this error is produced where i called "responseItems = svcClient.GetOrderList(credentials, accountId, criteria)".
I tried manipulate the criteria so the response result will be different, and the system does run a little longer if i remove most of the criteria. But in any case it keeps complaining with the above error.
as soon as i common out that line, no more complains about CLR object cannot be marshaled.

Wonder if anyone is using CA API in AX / X++ and may have any insights or advice to help solve this.

thanks.

Jeff

CA_OrderService.OrderServiceSoapClient  svcClient;
CA_OrderService.APICredentials  credentials;
CA_OrderService.OrderCriteria   criteria;
str accountId;
;
try
{
    new InteropPermission(InteropKind::ClrInterop).assert();

    //initialize a client
    //BP Deviation Documented
    svcClient = new CA_OrderService.OrderServiceSoapClient('OrderServiceSoap');

    //set up credentials
    //BP Deviation Documented
    credentials = new CA_OrderService.APICredentials();
    credentials.set_DeveloperKey(devKey);
    credentials.set_Password(pswd);

    //set up criteria
    //BP Deviation Documented
    criteria = new CA_OrderService.OrderCriteria();
    criteria.set_DetailLevel('High');
    criteria.set_ShippingStatusFilter('Unshipped');
    criteria.set_PaymentStatusFilter('Cleared');
    criteria.set_OrderCreationFilterBeginTimeGMT(sinceDateTime);
    criteria.set_OrderCreationFilterEndTimeGMT(endDateTime);

    //BP Deviation Documented
    responseItems = new CA_OrderService.APIResultOfArrayOfOrderResponseItem();

    //****************************************************************************************************

    responseItems = svcClient.GetOrderList(credentials, accountId, criteria);

    //****************************************************************************************************

    CodeAccessPermission::revertAssert();
}
catch
{
   error(bscClrUtil::getClrError());
}

Jeff Zhou

unread,
Oct 8, 2012, 7:09:55 PM10/8/12
to ca...@googlegroups.com
made a mistake on copy & paste.
the variable responseItems is also declared up top.

CA_OrderService.APIResultOfArrayOfOrderResponseItem responseItems;

dap...@gmail.com

unread,
Jun 14, 2013, 3:24:45 PM6/14/13
to ca...@googlegroups.com
Hey Jeff,
 
I too am integrating AX 2009 with CA. I'm just getting started. I think what you need is a more in-depth error message, as the one you are getting is the "catch all". Try this in your catch:
 
               }
                catch (Exception::CLRError)
                {
                    ex = CLRInterop::getLastException();
                    info(ex.ToString());
                    return SyncResult;
                }
                catch (Exception::CodeAccessSecurity)
                {
                    info("Code Access Security Error");
                    return SyncResult;
                }
                catch (Exception::Internal)
                {
                    ex = CLRInterop::getLastException();
                    if (ex)
                    {
                        info(ex.ToString());
                    }
                    else
                    {
                        info("Internal Error");
                    }
                    return SyncResult;
                }
                catch (Exception::Error)
                {
                    info("None of it worked (generic Exception)");
                    return SyncResult;
                }
            } 
 
 
I would be very interested in sharing code with you, as I have run into a few bumps myself.
Reply all
Reply to author
Forward
0 new messages