Due to a development in one customer, I've started to get deeper in the desing on the XMLPorts. Until this days, I didn't have any problem with them, but I started to find myself in troubles with the issue of namespaces.
I must create an XML file like this:
As yo can see, in the "ROClientIDHeader" node we can find a "xmlns:http://tempuri.org" attribute. I tried to design something like this:
defining this namespace:
Adding the tns prefix, the XML file looks like this:
As you cann see, seems to be right, but we don't need the "tns" prefix, also it seems that we don't need to define the "tempuri" namespace. Anyway, if I dont use the prefix, when exportin the XMl, I find this error:
Because I'm trying to define the node this way:
Which should be the way to create the "ROClientIDHeader" node with "xmlns="http://tempuri.org/"" attribute???
Thank you very much
XMLPorts are great. At least as long as you have very simple XML files that you need to export, and sometimes when importing.
For everything else I'm always writing it "by hand" in a codeunit using XML .net libraries. That allows you full control over what you're exporting, something I don't quite feel we have with XMLPorts. And once you have done it this way a couple of times (knows which Microsoft helper codeunits/functions to use), then it's not even that much harder.
Thank you for your answer. I've used .NET objects in other scenarios before. But now, I'm using XMLPort because of the issue of the namespace. In a previous development, I used XMLports for generating the electronic invoice in Spain, and I'm using that development as a base, because I've solved the namespaces in that case.
My XML in this case is almost created, I'm just finding the issue with that node, with the "tempuri.org" namespace...
And that is what Eric explained to you - Normally if you have a very simple XML then XmlPort make sense but normally when interacting over Web services it comes up with many namespaces along with attributes which turns out be a challenging part for Xmlports to handle.
Thank you, I've understood it..
At first it looks that it's not really mandatory that node, and I'm abble to solve the issue with the port. If not, I will work again with the codeunit, hopefully not, because I don't now how to manage the namespace issue with the DotNet or Automation variables