Category Archives: Web Service

Generate Next RecId for Dynamics AX Table from SSIS

If you want to insert records directly into the SQL database using SSIS, you cannot on-the-fly get RecId’s easily from SQL manipulation alone, so another option is reserving the Recid’s using x++ in an x++ job or service, for example:
To get the next Recid for SalesTable,use the below code and before printing the recid , suspendrecids() has to be call then after printing recid removeRecIdSuspension() method should be call….

static void getNextRecId(Args _args)
//Table that stores record ids details for tables
SystemSequences systemSequences;
Counter noOfResereveRecId;

///Suppose you wants to reserve 40 records

noOfResereveRecId = 40;

//Class that handles Record id generation
SystemSequence systemSequence = new SystemSequence();

select firstonly systemSequences
where systemSequences.tabId == Tablenum(SalesTable);

info(strFmt(‘Next record id: %1’,systemSequence.reserveValues(noOfResereveRecId, systemSequences.tabId)));

This job will take a table, and reserve one recId to be used that the system will simply ignore/skip. A word of caution, if you accidently reserve a huge number it’s not easy to get those reservations back, and int64’s do have a limit (albeit a huge number).

You could probably create a service in x++ that you could hit from your SSIS job where you tell a table name and an amount to reserve, and get an int64 back, that way you could automate the SSIS job.


Tags: , ,

AIF Webservice : Tracing Web Service calls

When using AIF through web services, you can be in the dark when you want to know what’s really going on in there.

I was looking in to the web.config file suddenly i have seen a tag to trace the AIF Web services.


<;!-- This is used for enabling tracing in retail and debug builds.
AIF Service processing stack outputs and information
messages used for debugging.
Possible values for the switch are Off, Warning,
Information, Critical, Verbose.
Change the switchValue to Information to enable tracing.
<sources >
<;source name="AifServiceProcessing" switchValue="Information">
<;listeners >
<;add name="TextWriterListener"
initializeData="AifServiceTrace.webinfo" >;
<;remove name="Default" />


by default the Inner tag switchValue="Off”> and i have changed in to  switchValue="Information">. I found this on MSDN and will show an example here of what the result of the tracing shows.

i have invoked the service through .net class . there should be a file named AifServiceTrace.Webinfo present with the tracing information : 

The following information can be viewed :

  • UserId’s
  • Message ID
  • Source and destination endpoint
  • Key Data XML
  • Return Data from Ax


AifServiceProcessing Information: 0 : SourceEndpointUser : rajdiscoms\axbcproxy
AifServiceProcessing Information: 0 : Logged on to Dynamics Ax successfully.
AifServiceProcessing Information: 0 : Incoming MessageId : 5af19da1-9532-4842-9522-2f499f012e50
AifServiceProcessing Information: 0 : Submitting User : rajdiscoms\axbcproxy
AifServiceProcessing Information: 0 : External Action :
AifServiceProcessing Information: 0 : Source Endpoint
AifServiceProcessing Information: 0 : Destination Endpoint
AifServiceProcessing Information: 0 : Parameter in request : <;BiliingDeterminants xmlns=""><SenderId xsi:nil="true" xmlns:xsi="" /><Rdm_BillingDeterminants class="entity"><_DocumentHash xsi:nil="true" xmlns:xsi="" /><BinderNo>798080</BinderNo><DiscomCode xsi:nil="true" xmlns:xsi="" /><OfficeCode>80980</OfficeCode><ScheduledForBillMonth xsi:nil="true" xmlns:xsi="" /><ScheduledForBillYear xsi:nil="true" xmlns:xsi="" /><TimeStamp xsi:nil="true" xmlns:xsi="" /><TokenIssueDate xsi:nil="true" xmlns:xsi="" /><TokenNo>90124</TokenNo><TotalConsumers xsi:nil="true" xmlns:xsi="" /></Rdm_BillingDeterminants></BiliingDeterminants>
AifServiceProcessing Information: 0 : Aif Message Xml Request: : <;?xml version="1.0" encoding="utf-16"?><Envelope xmlns=""><Header><MessageId>{5af19da1-9532-4842-9522-2f499f012e50}</MessageId><SourceEndpointUser>rajdiscoms\axbcproxy</SourceEndpointUser><SourceEndpoint /><DestinationEndpoint /><Action></Action></Header><Body><MessageParts xmlns=""><BiliingDeterminants xmlns=""><SenderId xsi:nil="true" xmlns:xsi="" /><Rdm_BillingDeterminants class="entity"><_DocumentHash xsi:nil="true" xmlns:xsi="" /><BinderNo>798080</BinderNo><DiscomCode xsi:nil="true" xmlns:xsi="" /><OfficeCode>80980</OfficeCode><ScheduledForBillMonth xsi:nil="true" xmlns:xsi="" /><ScheduledForBillYear xsi:nil="true" xmlns:xsi="" /><TimeStamp xsi:nil="true" xmlns:xsi="" /><TokenIssueDate xsi:nil="true" xmlns:xsi="" /><TokenNo>90124</TokenNo><TotalConsumers xsi:nil="true" xmlns:xsi="" /></Rdm_BillingDeterminants></BiliingDeterminants></MessageParts></Body></Envelope>
AifServiceProcessing Information: 0 : Return value from DynamicsAx : <;EntityKey xmlns=""><KeyData><KeyField><Field>TokenNo</Field><Value>90124</Value></KeyField></KeyData></EntityKey>


happy Daxing Smile


Tags: ,

Error:Update reference of Web service Wsdl

today i was facing the  trouble while updating the service reference in visual studio 2010. 

The following errors can be occurs because of the points mentioned below:

1. IIS is not running

2.Web service namespace has been changed.

3.Endpoint Address and Binding is changed




Leave a comment

Posted by on October 10, 2012 in Visual Studio, Web Service


Tags: ,

AIF: web service operations was not visible in Basic->Setup->AIF->Service.

At a customer’s site, I was creating  AIF Web services. i as trying to regenerating the web service.but i am not able to see the operation of that webservice in Basic->Setup->AIF->Service.


After a certain amount of regenerating and deleting the web service project and nearly giving up,  after lots of efforts i have  discovered that the AIF Wizard have imported the AIF operation’s with wrong id’s in AifAction table.


It probably means you have regenerated you classes using the AIF document wizard, or that you have imported the AIF classes with wrong id’s.


You can use this job to fix the class id’s in the AIFAction table:

static void FixAIFActions(Args _args)
AIFAction aIFAction;
AIFService aifService;
ClassId classId;

// inner method:
// spit string at delimeter, keep left substring
str lSplit( str _s, str _delimeter )
str s = "";
int pos;
int len = strlen( _s );

pos = strfind( _s, _delimeter, 0, len );
s = strdel( _s,pos,len-pos+1);

return s;
//Select Web service name
select aifService where aifService.Name == "BiliingDeterminantsService";
// fix all actions
while select aIFAction
// check if classid and classname matc.
if(lSplit(aIFAction.ActionId, '.') == aifService.Name)
// update classid
aIFAction.ClassId = classId;

info(strfmt('Action %1 updated', aIFAction.ActionId));



Tags: ,

AIF: HTTP Error 404.3 – Not Found

I have deployed the web service on IIS, I got an error when I tried to browse my web service
The error was:

HTTP Error 404.3 – Not Found

When I tried to add a web reference the svc in visual studio .NET, I got a similar error:

HTTP Error 404 – Not Found

I solved it by using the method described on the AIF blog:

Basically, execute the following command on your web server:

ServiceModelReg.exe -i -x


Related Links



Tags: ,

Dynamics AX AIF Web Service reference credential problem

At a client’s site, I was creating  AIF Web services. For this, I was using the service wizard in AX 2009.

The web service was deployed to the IIS 7.5.when i when i was trying to consume the web service through  the .Net application.the following happened : The service was prompting for credentials and did not work properly.


WCF Service Reference Credential Prompt



After a certain amount of searching time and nearly giving up,  I was browsing the configuration file of the web services directory and discovered that the BindingMethod of the deployed services was configured to use basicHttpBinding.


This was the actual problem because the wsdl looked like this : (negotiate authentication tags were added, …)



Changing the binding method to wsHttpBinding creates the service without the negotiateAuthentication and takes care of our annoying credential problem.



Tags: ,