Problem with XMLPorts: XML import
anafornies
Member Posts: 6
Hi!
I have a problem with an xml that I like import in NAV 2009 with XMLPorts.
My XML is:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header></env:Header>
<env:Body>
<ns0:getOperacionesResponse xmlns:ns0="http://gasoil.interna/">
<return xmlns:ns2="http://gasoil.interna/">
<item>
<cantidad>60.0</cantidad>
<claseTarjeta>0</claseTarjeta>
<codCliente>1</codCliente>
<codEstacionServicio>2986</codEstacionServicio>
<codOperacion>204479</codOperacion>
<codTarjeta>9999</codTarjeta>
<codTarjetaExterno>8899788532</codTarjetaExterno>
<conductor></conductor>
<fechaFactura>0001-01-01T00:00:00+01:00</fechaFactura>
<fechaOperacion>2010-08-31T23:59:59+02:00</fechaOperacion>
<kilometros>4440</kilometros>
<matricula>XX5BCB</matricula>
<numFactura></numFactura>
<precioUnitario>0.0</precioUnitario>
<producto>19</producto>
<productoDescripcion1>Gasoleo C</productoDescripcion1>
<productoDescripcion2></productoDescripcion2>
</item>
</return>
</ns0:getOperacionesResponse>
</env:Body>
</env:Envelope>
I had defined an XMLport with this structure (following this link: http://www.mibuso.com/forum/viewtopic.php?t=23618
Node Name Node Type Source Type Data Source
env:Envelope Element Text env:Envelope
xmlns:env Attribute Text NS1
env:Header Element Text <env:Header>
env:Body Element Text <env:Body>
ns0:getOperacionesResponse Element Text <ns0:getOperacionesResponse>
xmlns:ns0 Attribute Text NS2
return Element Text <return>
xmlns:ns2 Element Text NS3
item Element Table <Repostajes gasoil>(Repostajes gasoil)
cantidad Element Field <Repostajes gasoil>::cantidad
claseTarjeta Element Field <Repostajes gasoil>::claseTarjeta
codCliente Element Field <Repostajes gasoil>::codCliente
codEstacionServicio Element Field <Repostajes gasoil>::codEstacionServicio
codOperacion Element Field <Repostajes gasoil>::codOperacion
codTarjeta Element Field <Repostajes gasoil>::codTarjeta
codTarjetaExterno Element Field <Repostajes gasoil>::codTarjetaExterno
conductor Element Field <Repostajes gasoil>::conductor
fechaFactura Element Field <Repostajes gasoil>::fechaFactura
fechaOperacion Element Field <Repostajes gasoil>::fechaOperacion
kilometros Element Field <Repostajes gasoil>::kilometros
matricula Element Field <Repostajes gasoil>::matrícula
numFactura Element Field <Repostajes gasoil>::numFactura
precioUnitario Element Field <Repostajes gasoil>::precioUnitario
producto Element Field <Repostajes gasoil>::producto
productoDescripcion1 Element Field <Repostajes gasoil>::productoDescripcion1
productoDescripcion2 Element Field <Repostajes gasoil>::productoDescripcion2
In my XMLPort code:
OnPreXMLport()
NS1 := NSpace1;
NS2 := NSpace2;
NS3 := NSpace3;
Globals (Text Constants):
Name ConstValue
NSpace1 http://schemas.xmlsoap.org/soap/envelope/
NSpace2 http://gasoil.interna/
NSpace3 http://gasoil.interna/
My codeunit for import the XML.
importGasoil()
file.TEXTMODE(TRUE);
file.WRITEMODE(FALSE);
file.OPEN('c:\FacturacionGasoil.xml');
file.CREATEINSTREAM(inStream);
XMLPORT.IMPORT(XMLPORT::MyXMLPortGasoil,inStream);
I receipt a lot errors when I launch my codeunit for import this XML the first is "<Envelope> element doesn´t exists in description object".
Anybody had the same problem and found the solution?.
Thanks in advance!!
Ana
I have a problem with an xml that I like import in NAV 2009 with XMLPorts.
My XML is:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header></env:Header>
<env:Body>
<ns0:getOperacionesResponse xmlns:ns0="http://gasoil.interna/">
<return xmlns:ns2="http://gasoil.interna/">
<item>
<cantidad>60.0</cantidad>
<claseTarjeta>0</claseTarjeta>
<codCliente>1</codCliente>
<codEstacionServicio>2986</codEstacionServicio>
<codOperacion>204479</codOperacion>
<codTarjeta>9999</codTarjeta>
<codTarjetaExterno>8899788532</codTarjetaExterno>
<conductor></conductor>
<fechaFactura>0001-01-01T00:00:00+01:00</fechaFactura>
<fechaOperacion>2010-08-31T23:59:59+02:00</fechaOperacion>
<kilometros>4440</kilometros>
<matricula>XX5BCB</matricula>
<numFactura></numFactura>
<precioUnitario>0.0</precioUnitario>
<producto>19</producto>
<productoDescripcion1>Gasoleo C</productoDescripcion1>
<productoDescripcion2></productoDescripcion2>
</item>
</return>
</ns0:getOperacionesResponse>
</env:Body>
</env:Envelope>
I had defined an XMLport with this structure (following this link: http://www.mibuso.com/forum/viewtopic.php?t=23618
Node Name Node Type Source Type Data Source
env:Envelope Element Text env:Envelope
xmlns:env Attribute Text NS1
env:Header Element Text <env:Header>
env:Body Element Text <env:Body>
ns0:getOperacionesResponse Element Text <ns0:getOperacionesResponse>
xmlns:ns0 Attribute Text NS2
return Element Text <return>
xmlns:ns2 Element Text NS3
item Element Table <Repostajes gasoil>(Repostajes gasoil)
cantidad Element Field <Repostajes gasoil>::cantidad
claseTarjeta Element Field <Repostajes gasoil>::claseTarjeta
codCliente Element Field <Repostajes gasoil>::codCliente
codEstacionServicio Element Field <Repostajes gasoil>::codEstacionServicio
codOperacion Element Field <Repostajes gasoil>::codOperacion
codTarjeta Element Field <Repostajes gasoil>::codTarjeta
codTarjetaExterno Element Field <Repostajes gasoil>::codTarjetaExterno
conductor Element Field <Repostajes gasoil>::conductor
fechaFactura Element Field <Repostajes gasoil>::fechaFactura
fechaOperacion Element Field <Repostajes gasoil>::fechaOperacion
kilometros Element Field <Repostajes gasoil>::kilometros
matricula Element Field <Repostajes gasoil>::matrícula
numFactura Element Field <Repostajes gasoil>::numFactura
precioUnitario Element Field <Repostajes gasoil>::precioUnitario
producto Element Field <Repostajes gasoil>::producto
productoDescripcion1 Element Field <Repostajes gasoil>::productoDescripcion1
productoDescripcion2 Element Field <Repostajes gasoil>::productoDescripcion2
In my XMLPort code:
OnPreXMLport()
NS1 := NSpace1;
NS2 := NSpace2;
NS3 := NSpace3;
Globals (Text Constants):
Name ConstValue
NSpace1 http://schemas.xmlsoap.org/soap/envelope/
NSpace2 http://gasoil.interna/
NSpace3 http://gasoil.interna/
My codeunit for import the XML.
importGasoil()
file.TEXTMODE(TRUE);
file.WRITEMODE(FALSE);
file.OPEN('c:\FacturacionGasoil.xml');
file.CREATEINSTREAM(inStream);
XMLPORT.IMPORT(XMLPORT::MyXMLPortGasoil,inStream);
I receipt a lot errors when I launch my codeunit for import this XML the first is "<Envelope> element doesn´t exists in description object".
Anybody had the same problem and found the solution?.
Thanks in advance!!
Ana
0
Comments
-
Hello.
You need to run the function to remove namespaces from the xml file first before using xmlports. Search the forum and you'll find the function.0 -
It worked fine!!
Thank you very much!!!
Best regards!!0 -
That's great.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
