Skip to main content

Notifications

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

  • Pravasti AK Profile Picture
    2,985 on at
    RE: Error when accessing the service operation of AX service using c#

    Hi Martin,

    I got the below error message in event viewer,

    pastedimage1608396566830v2.png

  • Pravasti AK Profile Picture
    2,985 on at
    RE: Error when accessing the service operation of AX service using c#

    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.

  • Martin Dráb Profile Picture
    232,968 Most Valuable Professional on at
    RE: Error when accessing the service operation of AX service using c#

    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
    RE: Error when accessing the service operation of AX service using c#

    Hi,

    Please mention the bindings detail and end point configuration.

  • Pravasti AK Profile Picture
    2,985 on at
    RE: Error when accessing the service operation of AX service using c#

    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.

  • Martin Dráb Profile Picture
    232,968 Most Valuable Professional on at
    RE: Error when accessing the service operation of AX service using c#

    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?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,190 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans