web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

method is not a member of webservice class exception in ax2012

(0) ShareShare
ReportReport
Posted on by

1) consuming webservice through C# library project in AX2012r3

2) x++ does not give an error during compilation

3) during runtime it will throw and exception saying "methodname" is not a member of "webserviceclass" -- which is not true. I can see that method in that service in visual studio and it lets me choose that method in x++

just wondering what kind of solution you used on visual studio or on ax side. please let me know

Thank you,

Dp_ax

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    below is the code

    #define.UserId("#####")

       #define.Pass("#####")

       // This is the variable for the service client.

       ClrObject clientType;

       HOF_RapPriceRead.RapService.RapaportPricesSoapClient _client;

       //RapImportService.HOF_RapPriceService.LoginResponse  _authHeader; //.AuthenticationTicketHeader

       HOF_RapPriceRead.RapService.AuthenticationTicketHeader AuthenticationTicketHeader;

       HOF_RapPriceRead.RapService.AuthenticationTicketHeader AuthenticationTicketHeaderVal;

       HOF_RapPriceRead.RapService.RapaportPrice RapPriceClass;

       ClrObject priceType;

       HOF_RapPriceRead.RapService.RapaportPrice  _price;

       //HOF_RapPriceRead.RapService.GetPriceResponse priceResp;

       real price;

       str authTicket;

       str URLAuth,endPoint;

       System.Exception netException;

       HOF_RapPriceRead.RapService.LoginRequest inValue;

       ClrObject loginType;

       str oldAddress,newAddress;

       System.ServiceModel.EndpointAddress address;

       HOF_RapPriceRead.ImportMgr serviceClass;

       str serviceValues[], priceval;

       HOF_RapPriceRead.RapService.RapaportPricesSoapClient webServiceManager;

       //System.ServiceModel.EndpointAddress address;

       System.Type type;

       ;

       clientType = CLRInterop::getType("HOF_RapPriceRead.RapService.RapaportPricesSoapClient");

       //priceType = CLRInterop::getType("RapImportService.HOF_RapPriceService.RapaportPrice");

       type = CLRInterop::getType('HOF_RapPriceRead.RapService.RapaportPricesSoapClient');

       try

       {

       _client   = AifUtil::createServiceClient(type);

       }

       catch(Exception::CLRError)

       {

           info("Caught 'ExException::CLRError'.");

           netException = CLRInterop::getLastException();

           info(netException.ToString());

       }

       AuthenticationTicketHeaderVal = AuthenticationTicketHeader.get_Ticket();

       try

       {

    //upto here everthing is fine and it throw exception at run time saying Getprice is not a member of RapaportPricesSoapClient which is not True.

       _price = _client.GetPrice(AuthenticationTicketHeaderVal,'Round',0.8,'F', 'VS1');

       }

       catch(Exception::CLRError)

       {

           info("Caught 'ExException::CLRError'.");

           netException = CLRInterop::getLastException();

           info(netException.ToString());

       }

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Ensure yourself that the same version of the library has been deployed to both client and server. It's possible that what's executed on server isn't the same as what's used for compilation on client.

    Also note that the message can be caused by wrong types of parameters.

  • Community Member Profile Picture
    on at

    I guess the issue is AX can't pass "float" to C# methods. I tried doing it in simple not webservice  method of c#. I passed float and got same error then I changed argument type to string in c# and passed Str from x++ and is working.

    Unfortunetley I can't change method of THIRD party webservice which excepts one of its argument parameters as float and I can't pass float/real from x++ (it will throw exception with member not found).

    Please let me know if any solution is out there.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    .NET Interop from X++ does support marshaling from X++ real to CLR System.Single (float in C#).

    Please show me what type is expected by the method of the service client proxy (look at IntelliSense in AX) and the value you're passing in.

  • Community Member Profile Picture
    on at

    Hi Martin,

    it is

    _client.GetPrice(AuthenticationTicektHeader, string Shape, Single Size, sting color, string clarity)

    the Singel Size parameter is the issue

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    What if you use System.Single type instead of X++ real?

  • Verified answer
    Community Member Profile Picture
    on at

    yes I tired that but System.Single  did not help either, I finally ended up writing method in .dll  which will except float as a string from Ax and covert it to float in C# and works fine.

  • Douglas Noel Profile Picture
    3,905 on at

    Hi all,

    one of the really importantst differences between ax2009(and older) and ax2012 is the representation of the ax datatype real.

    Within 2009 this type is marshalled to .net double, in 2012 this type is bcd and marshalled to .net decimal.

    If you have a .NET dll something like

       public static class Statics

       {

           public static int DoSgl(Single a, Single b)

           {

               return 1;

           }

           public static int DoDbl(Double a, Double b)

           {

               return 1;

           }

           public static int DoDec(Decimal a, Decimal b)

           {

               return 1;

           }

          // overloads

           public static int DoGen(Single a, Single b)

           {

               return 10;

           }

           public static int DoGen(Double a, Double b)

           {

               return 11;

           }

           public static int DoGen(Decimal a, Decimal b)

           {

               return 12;

           }

       }

    If you now have a x++ real variable, let's say rvar = 24.34;

    You will see that a call from ax with TESTCALL.Static::DoGen(rvar, rvar)

    will lead to the result 11 (if called from Ax200) and 12 (if called from Ax2012)

    If you want to call a method with System.Single you must du the following workarounds:

    From Ax2009:  (double to single )

    ret = TESTCALL.Statics::DoSgl( System.Convert::ToSingle(rvar),  System.Convert::ToSingle(rvar));

    From Ax2012: (decimal to single)

    ret = TESTCALL.Statics::DoSgl( System.Decimal::ToSingle(rvar), System.Decimal::ToSingle(rvar));

    If we write dll's we always use overloads for all methods which are going to be accessed by dynamics 2009 and 2012

    For 2009 we use the double declaration, for 2012 the decimal declaration.

    If you use such overloads for each public method you want to use, you can use this dll with both versions.

    regards

    Douglas

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans