Trying to convert DESADV from XML to EDIFACT D96a?

Post author
David S

I'm sure I am missing something obvious.  I am using the .NET SDK (version 9.8.4 nuget) along with EdiFabric.Templates..Edifact v1.1.0 again via nuget.

I have managed to translate EDIFACT ORDERS to XML fine however, I am trying to convert DESADV XML to EDIFACT and having some trouble trying to, first of all, get a valid DESADV (Edifact D96a) XML to read and deserialize.

I have an XML of the DESADV that I have actually pasted into the EDI API online tool as an INTERCHANGE to generate the EDIFACT output and that works online.

When I then try the above XML via c#/SDK, I keep getting an error at the following line (T is type of TSDESADV):

var serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(xml.CreateReader());

<GenerateEdifactInterchange xmlns='http://schemas.datacontract.org/2004/07/EdiFabric.Web.Api.Models'> was not expected.

I guess I am trying to get either an XML example or Schema that is correctly formatted to be able to perform the XML to EDI process?

Sorry, bit new to this, any pointers much appreciated!

Comments

3 comments

  • Comment author
    David S

    Sorry! I hadn't yet discovered this:

     

    https://support.edifabric.com/hc/en-us/sections/360001507831-Code-Library?page=2#articles

     

     

    0
  • Comment author
    Admin

    Hi,

    The XML of DESADV reflects the DESADV itself. The GenerateEdifactInterchange XML is the XML representation of the GenerateEdifactInterchange operation on the API. They are two different objects and you can deserialize one onto the other.

    The GenerateEdifactInterchange contains groups, which themselves contain messages, such as DESADV.

    You'll need to either

    - iterate through each separate DESADV XML and deserialize it to DESADV object

    or

    - Deserialize the whole GenerateEdifactInterchange to object and iterate through the DESADV objects

    1
  • Comment author
    David S

    Many thanks for confirming/clarifying that - really appreciate it.

    0

Please sign in to leave a comment.