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);
}