Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using AIF:Calling methodes of the DataSource Table from .Net

98 views
Skip to first unread message

mhr

unread,
Aug 25, 2006, 12:05:02 PM8/25/06
to
Hi,
Although i think no one is going to answer this one because it seems a few
people are using AIF for .net application i will post my question and i hope
someone has idea about it.
I am using AIF for my web application (asp .net) and in Ax i have some
methodes in my table and this tables is in the datasource of the query that i
am using(the query for generating Axd classes). I wan to call this method
from .net but i dont know how..
Anyone can help?

Thanks

microsci

unread,
Aug 27, 2006, 2:27:01 AM8/27/06
to
If you are using AIF, why don't you use the WebService interface that is part
of DAX?

Using the .NET business connector will require you to instantiate all of the
classes necessary to create a datasource. I did this with the COM connector
in 3.0, and it was a lot work.

I have just completed a custom interface using the AIF webservice to process
data feeds from legacy mainframes and a .Net GUI application. I had to
understand the axd and ax class interactions.

mhr

unread,
Aug 27, 2006, 8:35:01 AM8/27/06
to
Hi,
I think it is also what i am doing now. I am using AX web services in .net.
I dont need to write the logics for creating, reading and finding records
because they are standard actions in AIF.(but i think for updating and
deleting i do need). About understanding Axd classes i got problem because it
is not well documented.
Do you have any suggestion for me?
As i asked also before I dont know how i can call a method of the table from
.net. Do you have any experience with this?

thanks in advance

microsci

unread,
Aug 27, 2006, 2:09:02 PM8/27/06
to
Just because the classes are not documented shouldn't keep you from achieving
your goals.
The following job will allow you to repeatedly send an xml file to the
AIFDocumentBroker

you can now set breakpoints in the axd.. classes.

static void AIFSend(Args _args)
{
AifEndpointId destEndpointId;
AifActionId actionId;
AifEntityKeyList entityKeyList;
AifMessageXml documentXml;
AifMessage message;
XMLDocument xmldoc;
str strxml;
;

destEndpointId = 'createListBooking';
actionId = 'createListBooking';
xmldoc = new XMLDocument();
doc.load(@"F:\dynamics\AIF\CreateListBooking.xml");
strxml = xmldoc.toString();


TTSBegin;

message = AifMessage::deserialize(strxml,destEndpointId);

message.actionId(actionId);

entityKeyList = AifDocumentBroker::create(message);

TTSCommit;
}

To answer your question regarding call methods from .net.
You create a class in X++ that performs the functions you need and then from
.net
call the static method(s).

using Microsoft.Axapta.BusinessConnector;

namespace BCNetSample1
{
/// <summary>
/// This sample uses the .NET Business Connector to
/// call an Axapta class static method.
/// </summary>
class Class1
{

/// <summary>
/// The main entry point for the application
/// </summary>
[STAThread]
static void Main(string[] args)
{

Microsoft.Axapta.BusinessConnector.Axapta ax;
string sID = "@SYS21669";
object o;
bool b;

try
{
// Create an Axapta object.
ax = new Axapta();

// Log on to Microsoft Dynamics AX.
ax.Logon("","","","");

}
catch (Exception e)
{
Console.WriteLine("An error occurred in object creation or Axapta logon:
{0}", e.Message);
return;
}

// Logon was successful.
try
{
// Call a static class method.
// In this example, call SysLabel::labelId2String2 to determine
// the label string for a given label ID.
o = ax.CallStaticClassMethod("SysLabel", "labelId2String2", sID);
}
catch (Exception e)
{
Console.WriteLine("An error has been encountered during
CallStaticClassMethod: {0}", e.Message);
b = ax.Logoff();
return;
}

// Output the returned string.
Console.WriteLine("The label string for {0} is {1}", sID, o.ToString());

// Log off from Axapta.
b = ax.Logoff();

mhr

unread,
Aug 28, 2006, 4:31:01 AM8/28/06
to
Thanks for the reply. but about using Business Connector for calling
method..Is there any way to use AIF and the webservices in order to call a
class method or table method? I woould like to use only AIF and not
combination of it with BC , if it was possible.

Thanks

Ricardo Venegas [MSFT]

unread,
Sep 5, 2006, 2:43:25 PM9/5/06
to
It depends if you want to call this method as part of the processing of an
standard action or call it just by Itself.

If you want to call this as part of the processing of an standard action.
1. Add a function your Axd Class that will manage the action (Pre-process or
post-process the message before calling the standard handler).
2. Edit the function GetActionList from your axd class and change the entry
for the action that you want to modify to call your function.

Ricardo Venegas [MSFT]


--
This posting is provided "AS IS" with no warranties, and confers no rights
"mhr" <m...@discussions.microsoft.com> wrote in message
news:87B585AF-10F2-42DF...@microsoft.com...

mhr

unread,
Sep 5, 2006, 4:50:02 PM9/5/06
to
Hi,
I have a table which has TableID and FieldID and Label as its fields.
Actually Label field is the label of the field with the id=FieldID from the
table with id=TableID. Si I should call a method to create label for me.

I need this method while I read the Ax Table in .net. So I think this method
needs to be called during processing of the standard action "Read".
I tried once what you said about adding method to the Axdclass. But i didnt
know how i can use it afterwards.
Could you please explain more about the second step ("Edit the function

GetActionList from your axd class and change the entry

for the action that you want to modify to call your function. ")

Thanks

Michael Merz [MSFT]

unread,
Sep 5, 2006, 7:13:01 PM9/5/06
to
Hi mhr,

If you need to call the method as part of a "standard method", i.e. a method
that comes out of the box, you would have to override that method. You do so
by opening the respective class in the AOT, navigating to the method and
editing it (e.g. adding the call to your method where you need it). Be sure
that you still execute the original code -- if you need that as well.

If you want to expose a (arbitrary) method on an Axd document class (the
class MUST inherit from AxdBase), more specifically a method that is not one
of the methods that comes with AX or that can be generated (i.e. create,
createList, read, readList, findList, findEntityKeyList), then you need to do
basically what Ricardo has recommended. Here are a few more details:

1) Open the AOT, navigate to “Classes”, double-click on the class to which
you want to add the new action.

2) Selects getActionList in the list on the left hand side of the form.

3) Create a new AifActionInfo record and add it to the method similar to the
following:

"//registering Delete method
aifActionInfo = new AifActionInfo();
aifActionInfo.parmActionId("DisplayName"); // Shows up on the “Action”
form
aifActionInfo.parmActionType(AifActionType::SendDocument); // Action
type, see below
aifActionInfo.parmExternalName("myExternalName");
aifActionInfo.parmMethodName("myMethodName"); // Name of the X++ method
aifActionInfo.parmLabel("someLabel");
aifActionInfo.parmDescription("someDescription");
aifActionInfo.parmDisplayMenuItemName(
menuitemdisplaystr(AifDocConfiguration));

actions.add(aifActionInfo);"

Save and close the dialog.

4) Right-click on the class to which you want to add the new action, select
"New Method", implement the method. Note that the implemented method must be
of the signature that is implicitly specified in 3), in
"aifActionInfo.parmActionType(AifActionType::SendDocument);". SendDocument,
used in the above code fragment for instance, would have to be a method of
the following signature:

AifDocumentXML <sendMethodName>( AifEntityKey entityKey, AifSchemaInfo
xsdInfo, AifEndpointActionPolicyInfo actionPolicyInfo, AifConstraintList
constraintList, AifPropertyBag propertyBag);

Note that each action that comes “out of the box”, implements either this or
one of the other supported signatures:
- SendDocumentList: AifDocumentXML < sendMethodName >( AifEntityKeyList
entityKeyList, AifSchemaInfo xsdInfo, AifEndpointActionPolicyInfo
actionPolicyInfo, AifConstraintListCollection constraintListCollection,
AifPropertyBag propertyBag);
- ReceiveDocument: AifEntityKey <createMethodName>( AifDocumentXMLxml,
AifEndpointActionPolicyInfo actionPolicyInfo, AifConstraintList
constraintList);
- ReceiveDocumentList: AifEntityKeyList <createMethodName>(
AifDocumentXMLxml, AifEndpointActionPolicyInfo actionPolicyInfo,
AifConstraintListCollection constraintListCollection);
- QueryEntityKeys: AifEntityKeyList <queryMethodName>( AifQueryCriteria
queryCriteria, AifEndpointActionPolicyInfo actionPolicyInfo);
- QueryDocuments: AifDocumentXML <queryMethodName>( AifQueryCriteria
querycriteria, AifSchemaInfo xsdInfo, AifEndpointActionPolicyInfo
actionPolicyInfo, AifConstraintListCollection constraintListCollection,
AifPropertyBag propertyBag);

5) Save your changes, compile the class, click “Scan and register” on the
Basic -> AIF -> Action form.

Now, if you open the Basic -> AIF -> Action form, you can see your method as
one of the actions on the respective document class. Note that this is an
advanced topic and as with all customizations, you need to be careful with
overriding any defaults.

Hope this helps,

-michael

--
This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages