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

Error when accessing the service operation of AX service using c#

(0) ShareShare
ReportReport
Posted on by

Hi,

I have used customer service ,when i try to access the service operation getting the below error,

static void Main(string[] args)
{
ServiceReference1.CustomerServiceClient c1 = new ServiceReference1.CustomerServiceClient();

// ServiceReference1.CriteriaElement elem = new ServiceReference1.CriteriaElement();

ServiceReference1.QueryCriteria qr = new ServiceReference1.QueryCriteria();
CriteriaElement[] qe = { new CriteriaElement { } };
EntityKey[] entityKey = { new EntityKey { } };

qe[0].DataSourceName = "CustTable";

qe[0].FieldName = "AccountNum";

qe[0].Operator = Operator.Equal;

qe[0].Value1 = "xxxxxx";
qr.CriteriaElement = qe;
Bcn.Axapta axp;

axp = new Bcn.Axapta();
axp.Logon(null, null, null, null);

// c1.ChannelFactory.Credentials.UserName.UserName = "xxxxxt";
//c1.ChannelFactory.Credentials.UserName.Password = "xxxxxx";
entityKey = c1.findKeys(qr);------------------------>Getting error "You cannot log on to Microsoft Dynamics AX.. Error details: Failed to initialize Business connector.. Check the Web server event viewer for more information, or contact your Administrator."
if (null == entityKey)
{
}
else
{
c1.read(entityKey);
}
}

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

    First of all, let me format your code, to make it easier to read. Please make sure you use Insert > Insert Code (in the rich-formatting view) to paste source code in future.

    static void Main(string[] args)
    {
    	ServiceReference1.CustomerServiceClient c1 = new ServiceReference1.CustomerServiceClient();
    
    	ServiceReference1.QueryCriteria qr = new ServiceReference1.QueryCriteria();
    	CriteriaElement[] qe = { new CriteriaElement { } };
    	EntityKey[] entityKey = { new EntityKey { } };
    
    	qe[0].DataSourceName = "CustTable";
    	qe[0].FieldName = "AccountNum";
    	qe[0].Operator = Operator.Equal;
    	qe[0].Value1 = "xxxxxx";
    	
    	qr.CriteriaElement = qe;
    	Bcn.Axapta axp;
    
    	axp = new Bcn.Axapta();
    	axp.Logon(null, null, null, null);
    
    	//c1.ChannelFactory.Credentials.UserName.UserName = "xxxxxt";
    	//c1.ChannelFactory.Credentials.UserName.Password = "xxxxxx";
    	entityKey = c1.findKeys(qr);------------------------>Getting error "You cannot log on to Microsoft Dynamics AX.. Error details: Failed to initialize Business connector.. Check the Web server event viewer for more information, or contact your Administrator."
    	if (null == entityKey)
    	{
    	}
    	else
    	{
    		c1.read(entityKey);
    	}
    }

    You're mixing web services and Business Connector. For example, you log into Business Connector but then don't use it for anything. It looks wrong to me.

    Did you complete the setup? Is the Business Connectory Proxy account valid?

    What did you find when you followed what the error message told you and checked event logs?

  • Pravasti AK Profile Picture
    2,985 on at

    After getting the error in find keys , I placed business connector code.

    1) Account is active.

    2) Do we need to connect Aos server to vs?

    3)I have used basichttpbinding,transport credential only, proxy credential type none.

  • Pravasti AK Profile Picture
    2,985 on at

    Hi,

    Please mention the bindings detail and end point configuration.

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

    1) Remove this code; it has no useful effect.

    2) Not apart from adding a service reference, which you already did. But don't forget all the other setup.

    3) How you should configure WCF depends on how you want to use it. Note that there are two sides - client and server. If you change just one of them, they may be unable to communicate. I'm not sure, but I think your problem isn't caused by WCF authentication, but by the setup of BC.

    It seems to me that you still didn't do what the error message told you and I reminded. Shouldn't you do it if you want to solve your problem?

  • Pravasti AK Profile Picture
    2,985 on at

    Hi Martin,

    I have captured the below error in the event log:,

    The configuration xxxx-USR could not be found.

    Use the Client configuration utility V5.0 to verify the configuration.

  • Pravasti AK Profile Picture
    2,985 on at

    Hi Martin,

    I got the below error message in event viewer,

    pastedimage1608396566830v2.png

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 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans