To change company using AIF Web Services

Hi All,

I am integrating AX 2009 with .net technology.

I am using AIF web services to do that.

AIF web services are working fine. now i have query How to pass a record in another company other than default company.

For e.g. My default company which is tagged to my user id is"Test1" but now i want to create a record from C# in another company “test2”.

Can anyone please tell me how to do it.

Regards

Aman Gupta

Hi Aman,

You can pass a record in another company other than default company using CallContext class.

Here is the example how to do it in C# code.

CustomerService.CallContext CustomerCtx = new CustomerService.CallContext();

CustomerCtx.Company = “test2”

CustomerCtx.Language = “en-us”;

In above code CustomerService is a service reference of CustCustomerService, and CustomerCtx is an object of CallContext class.

We can pass different company,language,user and other information as well.

Please let me know if this is what you are looking for.

Regards,

Vijay Solanki

Hi Vijay,

Thanx for reply…

But i am unable to find call context after declaring service reference.

Can you please elaborate.

Regards

Aman Gupta

Hi Aman,

As you are saying that you are unable to see call context class after adding service reference.

It might be possible that you are integrating AX 2009 AIF services with .net application.

In AX 2012 its working the same as i have mentioned.

I have to check for AX 2009 that what functionality they have provided to work in another company.

I’ll get back to you very soon.

Kind Regards,

Vijay Solanki.

Hi Aman,

As you are saying that you are unable to see callcontext class after adding service reference to .net application.

It might be possible that you are integrating AX 2009 AIf service to .net application.

but in AX 2012 it is working the same as i have mentioned.

I have to check for AX 2009. I’ll get back to you very soon.

Regards,

Vijay solanki.

Hi Aman,

Your user Id ‘Test1’ is connected to your default company.

Have you tried -

  1. Creating another user who is connected to the company you want to connect to (in this case ‘Test2’)

  2. And use this user in your code?

Hi Harish,

I think in your way it will definitely work. But suppose ‘User1’ which is connected to his default company ‘test1’ and he wants to do some operation using AIF services in ‘test2’ company with the same user then this won’t work. It means one user per company. It might be possible that one user can work in multiple companies.

In AX 2012 using AIF services, one user with proper roles and rights can access other company then the default company which is connected to it.

Regards,

Vijay Solanki.

Hi Vijay,

Yes - you are right. The solution I mentioned is essentially hard wired (i.e. one user to one company). I suggested this here in case if this solution is acceptable to the original poster.

Hi Vijay,

Could you please suggest me how to use that callcontext in AX 2009.When i declare instance of this

CallContext

callcontext = new CallContext();

it shows error though i am using namespace

using System.Runtime.Remoting.Messaging;

i checked in MSDN but it is all about AX 2012 and some settings are regarding inbound or outbound ports before using this callcontext.

So is there any way how to use this call context so that we can make use company specific or any settings are required for that ?

Define a new local endpoint in AX (Basic > Setup > Application Integration Framework > Local endpoints).

Set destination endpoint of your message - see Walkthrough: Updating Data with AIF for an example.

Hi Martin,

I am facing problem with CallContext not the stuffs what you provided that are only for inbound and outbound channel through which we can send data electronically as XML.

Hi Aman,

Did you get anything how to use this CallContext in AX 2009 ?

I am facing this problem from last couple of days.

Satya, this thread is about Aman’s question - create your own thread if you this is not about what you need.