Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Consuming an external service.

(0) ShareShare
ReportReport
Posted on by 529

So I built a class object to be able to consume in a class in D365.

namespace ExternalWebServices
{
    public class GetBDFFund
    {

        public string getXXXFunds(String billto, ref decimal CoopFunds, ref decimal AMFFunds, ref string strError)
        {
            string error = string.Empty;
            decimal AMFFFunds = 0;
            string pass = "ft89UL1aa7P4";
           // BasicHttpBinding httpBinding = new BasicHttpBinding();
            //EndpointAddress endPoint = new EndpointAddress(@"http://XXXdev.channel-fusion.com/asmx/FundByDealerNumber.asmx");

            var soapClient = new XXXSoap.FundByDealerNumberSoapClient();
            var usdToinr = soapClient.AvailableFunds(billto.ToString(), ref CoopFunds, ref AMFFFunds, ref strError, pass);
            return usdToinr.ToString();

        }

    }
}

In the D365 class I am getting an "}" expected at the list reference. I tried using just a simple var and it was giving me the same error. 

using ExternalWebServices;

internal final class ConsumeXXXFunds
{
    ExternalWebServices.GetBDFFund getXXXFunds = new ExternalWebServices.GetBDFFund();

    list funds = new strlist(Types::String);
    funds(0) = getXXXFunds.getXXXFunds("3333");
    Info(strFmt("%1", Funds);
}

  • KeithM Profile Picture
    KeithM 529 on at
    RE: Consuming an external service.

    It seems to be working ever since I adjusted the proper .NET version and change the assembly version. It isn't spitting the info like I thought it would but it's not erroring so that's a win in my book. I appreciate the help.

    Forum4.png

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Consuming an external service.

    I don't know use this approach, so I'm not sure if it actually updates the DLL file in the bin of your module. Please verify the version there, as discussed above.

    A reference just tells F&O what file to look for; the web server won't be able to loadit from your user profile folder. You must have the right DLL in the bin folder; the reference alone isn't sufficient.

    Personally, I prefer using project references rather than DLL references - then the reference and the DLL are added automatically (but they still need to be added to source control manually).

  • KeithM Profile Picture
    KeithM 529 on at
    RE: Consuming an external service.

    In the F&O project I simply delete the old reference to the dll from the C# class library and add a new reference to consume it.

    Forum2.png

    I went up a version and it shows as it should.

    Forum3.png

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Consuming an external service.

    Please tell me exactly you add the reference - I'm confused by your description.

    Also, verify that you have the right version of the DLL in the bin folder. A good idea may be increasing the assembly version number, building it, following your procedure to deploy the DLL (that I'll review when you describe it) and verify that the DLL in bin folder indeed has the right number.

  • KeithM Profile Picture
    KeithM 529 on at
    RE: Consuming an external service.

    Stratch that... it did pick it up and is giving me the same error as the other method.'

    Error Method 'GetStringInfo(System.String)' is not found on type 'ExternalWebServices.GetBDFFund'. GroupOConsumeSoap (ISV) [Fleet Management] K:\AosService\PackagesLocalDirectory\bin\XppSource\FleetManagement\AxClass_ConsumeMichelinFunds.xpp 21

  • KeithM Profile Picture
    KeithM 529 on at
    RE: Consuming an external service.

    Ok... I adjusted the method in the class library and added a simple string return. To which it didn't pick up when I removed and added in the reference again. All I do is clean and rebuild the class library dll.  Remove it from the F&O project and add the reference back in again from updated dll.

    namespace ExternalWebServices
    {
        public class GetBDFFund
        {
            public string getXXXFunds(String billto, decimal CoopFunds, decimal AMFFunds, string strError)
            {
                string pass = "ft89UL1aa7P4";
                BasicHttpBinding httpBinding = new BasicHttpBinding();
                EndpointAddress endPoint = new EndpointAddress(@"http://XXXdev.channel-fusion.com/asmx/FundByDealerNumber.asmx");
    
                //var soapclient = 
                var soapClient = new FundByDealerNumberSoapClient(httpBinding, endPoint);
                var usdToinr = soapClient.AvailableFunds(billto, ref CoopFunds, ref AMFFunds, ref strError, pass);
                return usdToinr.ToString();
    
            }
    
            public string GetStringInfo(string TestInput)
            {
                return TestInput;
            }
    
        }
    }

    It doesn't find it when try and select it with intelesense.

    4784.Forum1.png

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Consuming an external service.

    I don't see anything wrong with the method profile, although the fact that the ref parameters are useless looks suspicious at least. You also don't use some variables and calling ToString() on a string isn't very useful.

    Anyway, I have a few ideas about what to check.

    First of all, verify that the names are identical, including letter case. We can't verify that, because you change the names. (More preciselly, we can see that the names don't match, but I assume you made the mistake when obfuscating names before sharing.)

    Make sure you deployed the assembly correctly, especially if you're using a file reference (not a project reference).

    A good idea may be creating a new method for testing purpose, maybe with just a single string parameter. Then you can easily verify that the assembly was updated (because you'll see your new method) and you'll have a simpler case to test.

  • KeithM Profile Picture
    KeithM 529 on at
    RE: Consuming an external service.

    I thought it might of been that, but I have tried both ways. 

    class library program:   I recompiled and reapplied to my class in f&o.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using ExternalWebServices.XXXSoap;
    using System.ServiceModel;
    
    namespace ExternalWebServices
    {
        public class GetBDFFund
        {
            public string geXXXFunds(String billto, decimal CoopFunds, decimal AMFFunds, string strError)
            {
                string error = string.Empty;
                decimal AMFFFunds = 0;
                string pass = "ft89UL1aa7P4";
                BasicHttpBinding httpBinding = new BasicHttpBinding();
                EndpointAddress endPoint = new EndpointAddress(@"http://XXXdev.channel-fusion.com/asmx/FundByDealerNumber.asmx");
    
                var soapClient = new FundByDealerNumberSoapClient(httpBinding, endPoint);
                var usdToinr = soapClient.AvailableFunds(billto.ToString(), ref CoopFunds, ref AMFFFunds, ref strError, pass);
                return usdToinr.ToString();
    
            }
    
        }
    }

    Then I changed my isv for the class and method for D365: I still get that error: 
    Error Method 'getMichelinFunds(System.String, System.Decimal, System.Decimal, System.String)' is not found on type 'ExternalWebServices.GetBDFFund'. GroupOConsumeSoap (ISV) [Fleet Management K:\AosService\PackagesLocalDirectory\bin\XppSource\FleetManagement\AxClass_ConsumeMichelinFunds.xpp 19

    using ExternalWebServices.GetBDFFund;
    
    internal final class ConsumeXXXFunds
    {
    
        public void GetXXXFunds()
        {
    
            ExternalWebServices.GetBDFFund GetBDFFund = new ExternalWebServices.GetBDFFund();
    
            str billto = "1002711";
            real CoopFunds = 0;
            real AMFFunds = 0;
    
            var fund = "";
            var tempFund = GetBDFFund.getXXXFunds(billto,CoopFunds, AMFFunds, "");
            Info(strFmt("%1", fund));
        }
    
    }

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Consuming an external service.

    I think the problem is that you declared three parameters with 'ref', but you're passing normal parameters. The system looks for a method compatible with the parameters you passed, and it doesn't find any.

    I recommend not using ref parameters, but if you insist, change your code in GetXXXFunds() to actually use them.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Consuming an external service.

    Time to time, project references can cause problems. If you have made changes to External Web Services, the reference may not see the change. Did you make any changes?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans