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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Calling FO on premise services

(0) ShareShare
ReportReport
Posted on by 40

Hi all,

I'm having trouble calling GetLanguages (or any other method) from AxMetadataServiceClient service.

I can sucessfully obtain token, but actual call to GetLanguages method throws me Forbidden error

I'm using ADFS and use following urls:

relaying party : mydomain/.../AXSF

ADFS endpoint: myadfs/.../usernamemixed

I can see methods from https://mydomain/namespaces/AXSF/soap/Services/MetadataService/mex through my web browser

Did anyone succedded with  AX methods calls through ADFS?

string relyingPartyId = txtRelyingPartyId.Text;
string adfsEndpoint = txtADFSEndpoint.Text;

System.ServiceModel.Security.WSTrustChannelFactory factory = new System.ServiceModel.Security.WSTrustChannelFactory(
new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
new EndpointAddress(adfsEndpoint)
);

factory.TrustVersion = TrustVersion.WSTrust13;

var channelCredentials = factory.Credentials;
channelCredentials.UserName.UserName = txtUserName.Text;
channelCredentials.UserName.Password = txtPassword.Text;
channelCredentials.SupportInteractive = false;


System.IdentityModel.Protocols.WSTrust.RequestSecurityToken rst = new System.IdentityModel.Protocols.WSTrust.RequestSecurityToken
{
    RequestType = Microsoft.IdentityModel.Protocols.WSTrust.WSTrust13Constants.RequestTypes.Issue,
    AppliesTo = new EndpointReference(relyingPartyId),
    KeyType = Microsoft.IdentityModel.Protocols.WSTrust.WSTrust13Constants.KeyTypes.Bearer,
};

WindowsFormsApp1.ServiceReference1.AxMetadataServiceClient client = new AxMetadataServiceClient();

System.ServiceModel.Security.IWSTrustChannelContract channel = factory.CreateChannel();

System.Net.ServicePointManager.ServerCertificateValidationCallback  =
(se, cert, chain, sslerror) =>
{
    return true;
};

try
{
    SecurityToken token = channel.Issue(rst);
    MessageBox.Show("Token issued successfully. Valid from "   token.ValidFrom.ToString()   " to "   token.ValidTo.ToString());

    var proxy = client.ChannelFactory.CreateChannelWithIssuedToken(token);
    proxy.GetLanguages();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi tvinko1,

    Did you register client application to ADFS?

    Please refer to the following blog:

    docs.microsoft.com/.../authenticate-with-dynamics-365-for-finance-and-operations-web-services-in-on-premise

    It explains how to authenticate to an on-premises instance of Finance and Operations using ADFS application group.

  • tvinko1 Profile Picture
    40 on at

    Hi Will,

    thanks for pointers, but we went through all this steps

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 559 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 464 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans