Hi.
I've developed a .net app that reads xml sent from a navision xmlport. My problem is that I've created an Xmlport over the Customers table.
The table looks like this:
Customer (table)
No (field)
Name (field)
Address (field)
The xmlport maps the data correctly but when I try to parse the xml data in the .net app it throws an exception saying that the xml data contains several root elements. (only 1 is allowed in xml). Anyone know how to solve this?
I thought that the Xmlport would handle the creation of a well-structured
xml document.
/EC
0
Comments
<root>
<customer field1 field2 field3 />
<customer field1 field2 field3 />
</root>
e.g.:
someText (txt)
-Customer (table)
--No. (field)
--Name (field)
--Address (field)
But then the data isn't mapped to the xmlport.
Maybe if you filter the Customer Records when calling the XML Port helps:
RIS Plus, LLC
If I use my xmlport where the root is Customer it works perfectly when setting Customer.SETRANGE("No.", '10000')- that is ranging on 1 value. But when I set the range to '' it screws up.
Also I tried changing the Xmlport, as you said, so that I would have a root element of type text (btw, how do I set this root element?) but this does not work either, even when setting Customer.SETRANGE("No.", '10000') it stills screws up.
I am well aware of the xml syntax. But how do I create an XmlPort that comply to XML standards?
My XmlPort looks like this:
Customer (table)
-No (field)
-Name (field)
-Address (field)
I thought this was enough and that the XMLPort would handle the creation of the xml document in a well-structured fashion. Am I sadly mistaking?
What I did for an Item XMLPort is call my root element TempInboundItem (by the way, you can have different tag names and variable names, so be careful you keep them apart in your code) and import the XML document into the temp table. Because it's a temp table, everything is new, so everything gets imported. Then, in the OnPostXMLPort trigger I do something like this (the actual code does a lot more, but this is the basic idea): You could also do IF NOT INSERT THEN MODIFY, but that is less efficient code, and this way you can expand on each scenario.
RIS Plus, LLC
Can I ask exactly how are you running the XMLPort? It should work just fine. If the elements you showed us are all of your elements, then you have one root element and your xml should be well formed.
RIS Plus, LLC
I don't want to update existing records. All I'm interested in is to get a range of f.ex. Customers and export these to an XML file that I can use elsewhere.
I thought that XMLPort could be used to export Navision data to an XML file in an easy way instead of having to write the XML tags by hand.
It's a bit like running a report from code, and you need to send in the right record. There's a trick to it that you need to know. Once you know the trick it's not too complicated.
RIS Plus, LLC
I call a function with a parameter (No that indicates the customer."No.".
This function contains the following:
I've also tried:
None of the above works, when I filter on more than one customer (that is rCustomer.SETFILTER("No.", '') for example.
I call a function with a parameter (No that indicates the customer."No.".
This function contains the following:
I've also tried:
None of the above works, when I filter on more than one customer (that is rCustomer.SETFILTER("No.", '') for example.
This is what tht XML-Port should look like (I did not change any Properties, root has identation 0, customer has identation 1 and the other fields have identation 2):
If you want to export all the Customers, use:
Customer.SETFILTER("No."); (you should not use a FIND afterwards).
If this does not work, I can send you the objects.
I think it's the root element that's causing the problem. Because If I remove that it's works fine when filtering on f.example. rCustomer.SETFILTER("No.", '10000').
RIS Plus, LLC
Anyhow don't you mean rCustomer.SETRANGE("No.") instead of rCustomer.SETFILTER("No.") ??
It's not working either way. It's really beginning to bug me. I feel like I've tried everything.
I think if you have the Customer as the root element, then SETTABLEVIEW works, and if it's not the root element it doesn't work. The problem is though that if you use the Customer table as the root element, and you have more than one record, your XML is no longer well formed.
You're probably going to have to write a function inside your XMLPort to send in a customer record variable to use for exporting. I would have to experiment myself to make this work, and unfortunately right now I don't have much time.
RIS Plus, LLC
I just tried creating a test codeunit that creates a file, and streams the output from my xmlport to this file. It worked like a charm.
So the error must be somewhere else in my code.
Thanks for all the help and quick replies.
/EC
RIS Plus, LLC
The .Net app I've written and Navision communicates through MessageQueues.
So the thing I've been dealing with today was that when I export an XMLPort to the outStream that I'm using an error occurs. I don't know which error, but if I do myXmlPort.Export to an outstream created by a file everything works like a charm. But that's not what I want.
I want to export to the outStream that is being passed to the MessageQueue. (the outstream is initialized by
The strange thing is that when I export another xmlport I have it works fine but then again that Xmlport isn't mapped to a table. It just has one tag which is BigText.
Anyone can help with this or should I create a new topic?
RIS Plus, LLC
Even if I load the xml data from a file to a DOM object and then to the outstream it still don't work.
I'm not all that happy about working with flat files, as the data is to be transferred to a webservice.