Skip to main content

Notifications

Microsoft Dynamics AX (Archived)
Answered

Fault exception thrown by custom service

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fault exception thrown by custom service

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Fault exception thrown by custom service

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

  • Martin Dráb Profile Picture
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: AX Web services authentication

    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
    Community Member Microsoft Employee on at
    RE: AX Web services authentication

    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
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: AX Web services authentication

    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
    Community Member Microsoft Employee on at
    RE: AX Web services authentication

    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
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: AX Web services authentication

    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
    Community Member Microsoft Employee on at
    RE: AX Web services authentication

    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
    Martin Dráb 230,846 Most Valuable Professional on at
    RE: AX Web services authentication

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

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…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans