supertobi
supertobi

Reputation: 334

The update from my AIF Webservice for SalesAgreementHeader [AX 2012] fails

Hello I've created a query with only the SalesAgreementHeader as table. Then I used the wizard to create a document aif webservice. The webservice works fine, but the update always reports an "Invalid xml document." error. This error is thrown by the method moveToNextElement in the class AxdBaseCreate.

The reason for the exception is, that

reader.fieldName() = AgreementClassification 

and

_expectedElementName = AgreementRelationType.

How can I fix this? Or is there any good way to debug this?

Before I created the query with only the SalesAgreementHeader I had an more complex query and had the same error. Then I created a new one and reduced it to only the SalesAgreementHeader.

Update: A haven't solved the problem yet, but I think the problem could be because SalesAgreementHeader extends the AgreementHeader and the field RelationType is not visible in the AOS, but if you look directly in the DB.

Update 2: This is the call stack:

[s] \Classes\AxdBaseCreate\moveToNextElement 9

[s] \Classes\AxdBaseCreate\readSurrogateForeignKeyValue 37

[s] \Classes\AxdBaseCreate\readProperty 14

[s] \Classes\AxdBaseCreate\readProperties 122

[s] \Classes\AxdBaseUpdate\deserializeTopEntity 25

[s] \Classes\AxdBaseUpdate\deserializeDocument 131

[s] \Classes\AxdBaseUpdate\updateDocumentList 42

[s] \Classes\AxdBase\updateList 64

[s] \Classes\AifDocumentService\updateList 34

[s] \Classes\SalesAgreementService\update 4

Upvotes: 1

Views: 1358

Answers (1)

Yuriy
Yuriy

Reputation: 84

Could you please provide code which you're using?

I have an assumption (based on the name of AgreementRelationType it looks like this is Enim ) that you're trying to update field based on enum. If this is the case, then I hope I can help you.

When you need to update enum use following approach:

//here is an example how to change Status on SalesTable
//as you may see when you change the value of enum you have to set boolean autogenerated field to "true". 
//Name of such fields ends with suffix "Specified"
salesTable.SalesStatus = AxdEnum_SalesStatus.Invoiced;
salesTable.SalesStatusSpecified = true;

In advance I'd like to suggest you (in case you didn't do that) use following try..catch block. This will make your life easier.

try
{
    //your code here
}
catch (System.ServiceModel.FaultException<SalesOrderDelete.SalesOrderDeleteTcpNet.AifFault> aifFaults) // This code catches error messages even when "Logging mode = Logging is disabled" on Inbound port
{
    SalesOrderDelete.SalesOrderDeleteTcpNet.InfologMessage[] infologMessageList = aifFaults.Detail.InfologMessageList;

    foreach (SalesOrderDelete.SalesOrderDeleteTcpNet.InfologMessage infologMessage in infologMessageList)
    {

        Console.WriteLine("Exception: " + infologMessage.Message + "\n");
    }

    Console.WriteLine("\nPress any key to quit.\n");
    Console.ReadKey();
    cl.Abort();
}

Upvotes: 1

Related Questions