AX 4.0 Send GUID in AIF document
26. October 2010 Leave a comment
I’ve noticed a a bug in AX 4.0 (K/A: 4.0.2501.116) AIF implementation when using a table field type GUID. Unfortunately the generated XSD schema referred to the field type as Int64 instead of GUID. The sent XML of course contained an GUID String {00000000-1234-5678-9101-000000000000}. My C# .NET client reported an error because the received value was not a valid Int64.
I solved the problem by editing AxdBaseGenerateXSD.addGuid() method
protected void addGuid(
SysDictType dt,
XmlSchemaSimpleTypeRestriction restriction
)
{;
/* restriction.baseTypeName(XmlQualifiedName::construct(
this.addInt64Type(),
targetNameSpace)); */
SysDictType dt,
XmlSchemaSimpleTypeRestriction restriction
)
{;
/* restriction.baseTypeName(XmlQualifiedName::construct(
this.addInt64Type(),
targetNameSpace)); */
restriction.baseTypeName (XmlQualifiedName::construct(
this.addGuidType(),
targetNameSpace));
}
this.addGuidType(),
targetNameSpace));
}
As result the generated XSD schema contained the correct GUID definition
<xs:simpleType name=”AxdExtType_MyGUID“>
<xs:annotation>
<xs:documentation xml:lang=”DE-AT“>A Guid field</xs:documentation>
</xs:annotation>
<xs:restriction base=”AxdType_GUID” />
</xs:simpleType>
<xs:annotation>
<xs:documentation xml:lang=”DE-AT“>A Guid field</xs:documentation>
</xs:annotation>
<xs:restriction base=”AxdType_GUID” />
</xs:simpleType>
<xs:simpleType name=”AxdType_GUID“>
<xs:restriction base=”xs:string“>
<xs:minLength value=”38” />
<xs:maxLength value=”38” />
<xs:pattern
value=”({[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}})” />
</xs:restriction>
</xs:simpleType>
<xs:restriction base=”xs:string“>
<xs:minLength value=”38” />
<xs:maxLength value=”38” />
<xs:pattern
value=”({[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}})” />
</xs:restriction>
</xs:simpleType>