invalid message schema

Hi,

I tried using AIF and I encountered an error: Invalid message schema. I’ve search this error and I’m confuse what cause this error. I’m using a File system adapter for my enhanced inbound port. I’m trying to integrate my xml to create journal and journal lines.

I’d like to know how to fix this error. Any suggestions/explanation is greatly appreciated.

Thanks,

Schneizer

It seems that your XML isn’t in the right format.

Hi Martin,

this is my xml:

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

{5603D03A-4380-414D-9F27-738BE0FEA22E}

PRAA

MSDAXTEST\Administrator

http://schemas.microsoft.com/dynamics/2008/01/services/LedgerGeneralJournalService/create

OR

Daily Journal 1

Ledger

50

PHP

10100107—00000006

Ledger

10100104

2007-05-28

AxLedgerJournal inbound test trans 1

this is my schema when view on Data Policy:

<?xml version="1.0" encoding="utf-16" ?>

<xs:import schemaLocation=“SharedTypes.xsd” namespace=“http://schemas.microsoft.com/dynamics/2008/01/sharedtypes” />

<xs:element name=“LedgerGeneralJournal” type=“tns:AxdLedgerGeneralJournal” />

  • <xs:complexType name=“AxdLedgerGeneralJournal”>

  • xs:sequence

<xs:element minOccurs=“0” maxOccurs=“unbounded” name=“LedgerJournalTable” type=“tns:AxdEntity_LedgerJournalTable” />

</xs:sequence>

</xs:complexType>

  • <xs:complexType name=“AxdEntity_LedgerJournalTable”>

  • xs:sequence

<xs:element minOccurs=“1” name=“JournalName” type=“st:AxdExtType_LedgerJournalNameId” />

<xs:element minOccurs=“0” name=“Name” nillable=“true” type=“st:AxdExtType_Name” />

<xs:element minOccurs=“0” maxOccurs=“unbounded” name=“LedgerJournalTrans” type=“tns:AxdEntity_LedgerJournalTrans” />

</xs:sequence>

<xs:attribute fixed=“entity” name=“class” use=“required” />

<xs:attribute name=“action” type=“st:AxdEnum_AxdEntityAction” />

</xs:complexType>

  • <xs:complexType name=“AxdEntity_LedgerJournalTrans”>

  • xs:sequence

<xs:element minOccurs=“0” name=“AccountType” nillable=“true” type=“st:AxdEnum_LedgerJournalACType” />

<xs:element minOccurs=“0” name=“AmountCurCredit” nillable=“true” type=“st:AxdExtType_AmountCurCredit” />

<xs:element minOccurs=“0” name=“AmountCurDebit” nillable=“true” type=“st:AxdExtType_AmountCurDebit” />

<xs:element minOccurs=“0” name=“CurrencyCode” nillable=“true” type=“st:AxdExtType_CurrencyCode” />

<xs:element minOccurs=“0” name=“DefaultDimension” nillable=“true” type=“st:AxdType_DimensionAttributeValueSet” />

<xs:element minOccurs=“0” name=“LedgerDimension” nillable=“true” type=“st:AxdType_MultiTypeAccount” />

<xs:element minOccurs=“0” name=“OffsetAccountType” nillable=“true” type=“st:AxdEnum_LedgerJournalACType” />

<xs:element minOccurs=“0” name=“OffsetDefaultDimension” nillable=“true” type=“st:AxdType_DimensionAttributeValueSet” />

<xs:element minOccurs=“0” name=“OffsetLedgerDimension” nillable=“true” type=“st:AxdType_MultiTypeAccount” />

<xs:element minOccurs=“0” name=“TransDate” nillable=“true” type=“st:AxdExtType_TransDate” />

<xs:element minOccurs=“0” name=“Txt” nillable=“true” type=“st:AxdExtType_LedgerJournalTransTxt” />

</xs:sequence>

<xs:attribute fixed=“entity” name=“class” use=“required” />

<xs:attribute name=“action” type=“st:AxdEnum_AxdEntityAction” />

</xs:complexType>

</xs:schema>

I’m not much familiar with xml and xsd. I don’t know where did i go wrong.

Thanks,

Schneizer

This is the schema (http://schemas.microsoft.com/dynamics/2008/01/documents/Message):

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema targetNamespace="http://schemas.microsoft.com/dynamics/2008/01/documents/Message" 
            xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message" 
            xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            elementFormDefault="qualified">
	
	<xsd:element name="Envelope" type="EnvelopeType"/>
	<xsd:element name="MessageParts" type="MessagePartsType"/>

	<xsd:complexType name="EnvelopeType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en-us">Envelope of the message.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
            <xsd:element name="Header" type="HeaderType"/>
            <xsd:element name="Body" type="BodyType"/>
        </xsd:sequence> 
    </xsd:complexType>
    
    <xsd:complexType name="HeaderType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en-us">Header containing message metadata.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>          
            <xsd:element name="MessageId" type="xsd:string" minOccurs="0"/>
            <xsd:element name="SourceEndpointUser" type="xsd:string" minOccurs="0"/>
            <xsd:element name="SourceEndpoint" type="xsd:string" minOccurs="0"/>
            <xsd:element name="DestinationEndpoint" type="xsd:string" minOccurs="0"/>
            <xsd:element name="Action" type="xsd:string"/>
            <xsd:element name="ConversationId" type="ConversationIdType" minOccurs="0"/>
            <xsd:element name="RequestMessageId" type="xsd:string" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

	<xsd:complexType name="BodyType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en-us">Body of the message.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="MessageParts" type="MessagePartsType"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:simpleType name="ConversationIdType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en-us">Conversation identifier of the message.</xsd:documentation>
		</xsd:annotation>
		<xsd:restriction base="xsd:string">
			<xsd:minLength value="1"/>
			<xsd:maxLength value="256"/>
		</xsd:restriction>
	</xsd:simpleType>

	<xsd:complexType name="MessagePartsType">
		<xsd:annotation>
			<xsd:documentation xml:lang="en-us">Zero or more parts of the message.</xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:any namespace="##any" processContents="skip"/>
		</xsd:sequence>
	</xsd:complexType>

</xsd:schema>

As you can see, it doesn’t contain Company and LogonAsUser elements.

Either your data is wrong or you’re using a wrong schema. Another version, http://schemas.microsoft.com/dynamics/2011/01/documents/Message, does support these elements.

By the way, you can test your XML by passing it to AifMessage::deserialize().

Hi Martin,

I removed the Company and LogonAsUser elements. I think my data is wrong because i don’t have an idea how to read the schema. I also dont know how to use the AifMessage::deserialize(). Can you give me an idea how to solve this issue?

Thanks!

Schneizer

Calling deserialize() is easy - it has merely two (mandatory) string parameters. See the following example:


```
str message = '<?xml version="1.0" encoding="utf-8" ?>'
+'<Envelope xmlns = "http://schemas.microsoft.com/dynamics/2008/01/documents/Message">'
+    '<Header>'
+        '<MessageId>{5603D03A-4380-414D-9F27-738BE0FEA22E}</MessageId>'
+        '<Company>PRAA</Company>'
+        '<LogonAsUser>administrator</LogonAsUser>'
+        '<Action>http://schemas.microsoft.com/dynamics/2008/01/services/LedgerGeneralJournalService/create</Action>'
+    '</Header>'
+    '<Body>'
+        '<MessageParts xmlns = "http://schemas/microsoft.com/dynamics/2008/01/documents/Message">'
+          '<LedgerGeneralJournal xmlns = "http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal">'
+        '</LedgerGeneralJournal>'
+        '</MessageParts>'
+    '</Body>'
+ '</Envelope>';
    ;
    
    AifMessage::deserialize(message, 'administrator');
```

Hi Martin,

I’ve reconstructed the xml to be imported on AX 2012. But I’m still encountering some errors:

There is no service with namespace = ‘http://schemas.microsoft.com/dynamics/2011/01/services’ and external name = ‘LedgerGeneralJournalService’.

what does this means? I can’t access http://schemas.microsoft.com/dynamics/2011/01/services when i tried searching it on a browser?

Thanks,

Schneizer

It means that AX (AifService table) doesn’t contain any service with namespace “http://schemas.microsoft.com/dynamics/2011/01/services” and external name “LedgerGeneralJournalService”.

If you’re trying to use LedgerGeneralJournalService in AX2012, notice that its default external name is “GeneralJournalService” and namespace “http://schemas.microsoft.com/dynamics/2008/01/services” - check properties of the service node (AOT > Services > LedgerGeneralJournalService).

Don’t bother opening the URI in browser - it’s just a name of the schema, not an address.

Hi Martin!

I’m still encountering this error: Invalid message schema.

Here is my xml:

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

{6432E03A-4380-414D-9F37-732BE0FEA45E}

http://schemas.microsoft.com/dynamics/2008/01/services/GeneralJournalService/create

JournalNa1

Test 1

Ledger

0

50

PRAA

PHP

2007-05-28

AxLedgerJournal inbound test trans 1

Ledger

50

0

PRAA

PHP

2007-05-28

AxLedgerJournal inbound test trans 1

Here is my schema.

<?xml version="1.0" encoding="utf-16"?>

<xs:schema xmlns:tns=“http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal” xmlns:st=“http://schemas.microsoft.com/dynamics/2008/01/sharedtypes” elementFormDefault=“qualified” targetNamespace=“http://schemas.microsoft.com/dynamics/2008/01/documents/LedgerGeneralJournal” xmlns:xs=“http://www.w3.org/2001/XMLSchema”>

<xs:import schemaLocation=“SharedTypes.xsd” namespace=“http://schemas.microsoft.com/dynamics/2008/01/sharedtypes” />

<xs:element name=“LedgerGeneralJournal” type=“tns:AxdLedgerGeneralJournal” />

<xs:complexType name=“AxdLedgerGeneralJournal”>

xs:sequence

<xs:element minOccurs=“0” maxOccurs=“unbounded” name=“LedgerJournalTable” type=“tns:AxdEntity_LedgerJournalTable” />

</xs:sequence>

</xs:complexType>

<xs:complexType name=“AxdEntity_LedgerJournalTable”>

xs:sequence

<xs:element minOccurs=“1” name=“JournalName” type=“st:AxdExtType_LedgerJournalNameId” />

<xs:element minOccurs=“0” name=“Name” nillable=“true” type=“st:AxdExtType_Name” />

<xs:element minOccurs=“0” maxOccurs=“unbounded” name=“LedgerJournalTrans” type=“tns:AxdEntity_LedgerJournalTrans” />

</xs:sequence>

<xs:attribute fixed=“entity” name=“class” use=“required” />

<xs:attribute name=“action” type=“st:AxdEnum_AxdEntityAction” />

</xs:complexType>

<xs:complexType name=“AxdEntity_LedgerJournalTrans”>

xs:sequence

<xs:element minOccurs=“0” name=“AccountType” nillable=“true” type=“st:AxdEnum_LedgerJournalACType” />

<xs:element minOccurs=“0” name=“AmountCurCredit” nillable=“true” type=“st:AxdExtType_AmountCurCredit” />

<xs:element minOccurs=“0” name=“AmountCurDebit” nillable=“true” type=“st:AxdExtType_AmountCurDebit” />

<xs:element minOccurs=“0” name=“Company” nillable=“true” type=“st:AxdExtType_SelectableDataArea” />

<xs:element minOccurs=“0” name=“CurrencyCode” nillable=“true” type=“st:AxdExtType_CurrencyCode” />

<xs:element minOccurs=“0” name=“DefaultDimension” nillable=“true” type=“st:AxdType_DimensionAttributeValueSet” />

<xs:element minOccurs=“0” name=“OffsetDefaultDimension” nillable=“true” type=“st:AxdType_DimensionAttributeValueSet” />

<xs:element minOccurs=“0” name=“TransDate” nillable=“true” type=“st:AxdExtType_TransDate” />

<xs:element minOccurs=“0” name=“Txt” nillable=“true” type=“st:AxdExtType_LedgerJournalTransTxt” />

</xs:sequence>

<xs:attribute fixed=“entity” name=“class” use=“required” />

<xs:attribute name=“action” type=“st:AxdEnum_AxdEntityAction” />

</xs:complexType>

</xs:schema>

I’m still confused in this error since it doesn’t tell where my syntax is wrong on my xml.

Thanks!

Schneizer

The schema you have showed applies only to the LedgerGeneralJournal node of the XML file - are you aware of that? Your previous problem was in the format of the SOAP message header (= another schema) - are you sure you have resolve it?

You can use tools like Visual Studio for validating XML files against schemas and debugging them.

Do you know what? Don’t do it manually - consume the service in Visual Studio, fill data through the classes generated from the service description and log the resulting XML message.