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)
Answered

Fault exception thrown by custom service

(0) ShareShare
ReportReport
Posted on by

I have created a service class that should return the same data passed to the service (for testing purposes). The idea of hosting a web service on IIS instead of AOS is that I cannot use Windows authentication, as this service will be used by different domain users.

This service has been exposed and I created an HTTP Inbound port, set up as described here (https://blogs.msdn.microsoft.com/axsupport/2013/04/23/how-to-implement-basic-authentication-with-dynamics-ax-2012-web-services/). I am able to add the service reference in a visual studio console application, and I am also asked the credentials (which is what I need). the credentials are correct and accepted.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConsoleApplication.H5PortalService;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {

            TestServiceClient proxy = new TestServiceClient();
            proxy.ChannelFactory.Credentials.UserName.UserName = @"username"
            proxy.ChannelFactory.Credentials.UserName.Password = "password";
            CallContext context = new CallContext();


            try
            {
                proxy.processString(context, "testRequest");
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
    }
}


When I call the service (proxy.processString) I get an System.ServiceModel.FaultException error. IIS is configured ok and validated.

any ideas on how to resolve the issue?

Thanks

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    What is inside the FaultException? Is it really something about authentication?

  • Community Member Profile Picture
    on at

    I was not able to debug futher. Inner exception is null and the server stack trace System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc).

    I dont believe it is an authentication issue, as when I enter incorrect credentials, I get an authentication exception instead.

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

    Doesn't it have a message, at least?

    If you agree that it's not about authentication, why did you set the title to "AX Web services authentication"?

  • Community Member Profile Picture
    on at

    The message is - "an error occured". Not really helpful.

    When I was writing the post I believed it could be an authentication issue, but on further testing it seems that it is not.

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

    My assumption is that your service is called (without any authentication failure) but it throws an exception. If it's the case, debug your service to see where it fails.

  • Community Member Profile Picture
    on at

    That was my initial assumption as well, however, I have tested the same service using a simple netTCP inbound port instead of HTTP, and it worked just fine. Additionally, I created a very simple service class as below and I get the same exception result.

    [SysEntryPointAttribute(true)]

    public str processString(str _request)

    {

       return _request;

    }

    I beleive the issue is probably something to do with the service configuration, but I do not know what I have wrong or where to start unfortunately...

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

    There are several things you can do.

    First of all, make sure that your CIL and service references are up to date.

    Get everything possible from the exception. Look at it in debugger and check its exact type, all fields etc. (It may be, and typically is, a subtype of FaultException with additional details).

    Check event logs.

    I would still use debugger to debug the service, to understand whether it fails before calling the service.

    And if everything else fails, use tracing to analyze what exactly was called and where it failed.

  • Community Member Profile Picture
    on at

    I will try the above suggestions thanks. I will post the solution here when I find it.

  • Verified answer
    Community Member Profile Picture
    on at

    Found the solution. Was able to catch the exception that was being thrown by AX, and it seemed that the requested company could not be determined. I solved the issue by adding this line of code

    context.company = "NLD";

    that was all. Thanks

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