Charlie Mott

  Home  |   Contact  |   Syndication    |   Login
  20 Posts | 0 Stories | 18 Comments | 0 Trackbacks

News

View Charlie Mott's profile on LinkedIn



Archives

Post Categories

Friday, May 6, 2011 #

Article Source: http://geekswithblogs.net/charliemott

How do you send "Call Context" information in the header message to Dynamics AX 2012 WCF services from BizTalk? 

One difference between AX 2009 and AX 2012 services, is that you no longer always need to provide destination endpoint context information. This is described here:

In previous releases, each AIF endpoint was associated with a specific company. Microsoft Dynamics AX 2012 does not require that you associate integration ports with a specific company. You can use the integration port functionality to restrict service calls to a specific company. For an inbound message, the services framework obtains the company from the message header. If the message header does not contain a company context, the services framework uses the default company for the submitting user.

Adding WCF.OutboundCustomHeaders

In my requirement, I did need to send the Company code.

There is a very good article here about making BizTalk send header information to AX 2009 using WCF Services.

However, the implementation is slightly different with AX 2012. The schema namespace you need is http://schemas.microsoft.com/dynamics/2010/01/datacontracts

So the code will look like this. Notice I have only provided the header context information needed:

wcfHeader = System.String.Format(@"<headers><CallContext xmlns=""http://schemas.microsoft.com/dynamics/2010/01/datacontracts""><Company>{0}</Company></CallContext></headers>", companyCode);

msgRequest(WCF.OutboundCustomHeaders) = wcfHeader;

Other Tips

You may need to increase the size of the WCF-NetTcp adapter "Maximum receive message size". Otherwise, if the responses are large, you may get a System.ServiceModel.CommunicationException: The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.