AIF - AX 2009 - WebSerive


I would like to consume AIF WebService CustCustomerService. Below is my c# code. I get error when executing code.
What I should to do to resolve my error?

AIF Exception form

Element ‘MessageParts’ with namespace name '…/Message’ was not found. Line 1, position 2.

custAif.CustomerServiceClient proxy = new custAif.CustomerServiceClient();

custAif.QueryCriteria qc = new axAIFWebService.CustomerService.QueryCriteria();
custAif.CriteriaElement[] qe = { new axAIFWebService.CustomerService.CriteriaElement() };

custAif.EntityKey entityKey = new axAIFWebService.CustomerService.EntityKey();

qe[0].DataSourceName = “CustTable”;
qe[0].FieldName = “AccountNum”;
qe[0].Operator = axAIFWebService.CustomerService.Operator.Equal;
qe[0].Value1 = “OPO9999”;
qe[0].Value2 = “OKR0247”;

qc.CriteriaElement = qe;

custAif.AxdCustomer custTable = proxy.find(qc);


What’s the purpose of the empty entity key? Isn’t it cause the problem? And why did you set Value2 if there is no range?

Try to fix these things first - even if it doesn’t resolve the problem, you’ll get better code.

BTW you can avoid prefixing all types with custAif by adding using custAif on the top of the file.

I copied example from MS sites. MS use method findkey and they need EntityKey.

I commented entityKey and value2 but I still get error.

Maybe do you have working example how to consume AIF WebService?

I don’t have any AX 2009 on hand in the moment, but this works fine in my AX 2012:

CriteriaElement element = new CriteriaElement()
    DataSourceName = "CustTable",
    FieldName = "AccountNum",
    Operator = Operator.Equal,
    Value1 = "US-001"

QueryCriteria criteria = new QueryCriteria()
    CriteriaElement = new [] { element }

CustomerServiceClient client = new CustomerServiceClient();
AxdCustomer customer = client.find(new CallContext(), criteria);

@Martin I get the same error with your code.

I reviewed once again AIF configuration and I think it is ok. I supose there is problem with my c# call.

Below is schema for find customerService

<?xml version="1.0" encoding="utf-8" ?>
  • <xsd:schema targetNamespace=“” xmlns=“” xmlns:xsd=“” elementFormDefault=“qualified”>
    <xsd:element name=“QueryCriteria” type=“QueryCriteria” />
  • <xsd:complexType name=“QueryCriteria”>
  • <xsd:sequence minOccurs=“1” maxOccurs=“unbounded”>
    <xsd:element name=“CriteriaElement” type=“CriteriaElement” />
  • <xsd:complexType name=“CriteriaElement”>
  • xsd:sequence
    <xsd:element name=“DataSourceName” type=“xsd:string” />
    <xsd:element name=“FieldName” type=“xsd:string” />
    <xsd:element name=“Operator” type=“Operator” />
    <xsd:element name=“Value1” type=“xsd:string” />
    <xsd:element name=“Value2” type=“xsd:string” minOccurs=“0” />
  • <xsd:simpleType name=“Operator”>
  • <xsd:restriction base=“xsd:string”>
    <xsd:enumeration value=“Equal” />
    <xsd:enumeration value=“NotEqual” />
    <xsd:enumeration value=“Greater” />
    <xsd:enumeration value=“GreaterOrEqual” />
    <xsd:enumeration value=“Less” />
    <xsd:enumeration value=“LessOrEqual” />
    <xsd:enumeration value=“Range” />

Here is document history form Basic/periodic/AIF/Document history

<?xml version="1.0" encoding="UTF-8" ?>


Document format is ok?