Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 73760

Using AX Service within other AX environment - Problem with getting retrieved list into an x++ list

$
0
0

 

I have a C# Project called Tutorial. This Project includes a Service Reference TutorialServiceRef to an AX Service called TutorialService. The Service reference has the following settings:

  • Client
    • Address: http://aosserver:8101/DynamicsAx/Services/tutorialService
    • Access level for generated classes: public
  • Data Type
    • Always generate message conracts: No
    • Collection type: System.Array
    • Dictionary collection type: System.Collections.Genereic.Dictionary
    • Reuse types in referenced assemblies: Yes
      • Reuse types in all referenced assemblies: Yes

This service reference has the following classes (only the important ones are listed)

  • Class CallContext
  • Class tutorialServiceClient
  • Class tutorialServiceGetVendorRequest
  • Class tutorialServiceGetVendorResponse
  • Class VendAccountDC

The class TutorialServiceClient has a method called getVendors which collects all Vendors from a specified dataArea and puts it into a List of class Tutorial.TutorialServiceRef.VendAccountDC. The Service calles the x++ class Tutorial.getVendors

class Tutorial
{
    [AifCollectionTypeAttribute('return', 
     Types::Class, 
     classStr(VendAccountDC)), 
     SysEntryPointAttribute(true)]
 
    public List getVendors(str _parameter)
    {
        str       dataArea;
        container parameter = SysOperationHelper::base64Decode(_parameter);
        int       parameterVersion = any2int(conPeek(parameter, 1));
 
        switch (parameterVersion)
        {
            case 1:
 
                [parameterVersion,
                 dataArea] = parameter;
 
                return lukService::getVendors(dataArea); // returns a List of VendAccountDC data contracts
        }

        return new List(Types::Class);
    }
}

I now use this reference in my x++ job and want to populate there a list containing x++ classes of type VendAccountDC. But i do not know how I can retrieve the serviceClient.getVendors() return value into an x++ object. I get the error 'Clr Interop Marshal: Unsupported type.'

static void getVendorsJob(Args _args)
   List ret;
    str  parameter = SysOperationHelper::base64Encode([1, '001']);
 
    tutorial.tutorialServiceRef.tutorialServiceClient    serviceClient;
    tutorial.tutorialServiceRef.CallContext              context;
 
    serviceClient = new tutorial.tutorialServiceRef.tutorialServiceClient();
 
    context = new tutorial.tutorialServiceRef.CallContext();
    context.set_Company('002');
 
    ret = serviceClient.getVendors(context, parameter)   
}

I tried System.Collection.ArrayList instead of x++ List but this does not work either. The return value of serviceClient.getVendors() is 'tutorial.tutorialServiceRef.lukVTVendAccountDC[]'. How is it possible to retrieve this serviceClient.getVendors() in x++?

 


Viewing all articles
Browse latest Browse all 73760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>