Empty Namespace in XML

AK
Member Posts: 226
Hi,
I hope it's ok to post that problem here, because it might be related to using MSXML, which seems the only way to properly handle XML in the classic client.
I found some old code to consume a web service with C/AL, but it doesn't work. I suppose due to changes between MSXML versions.
The relevant part looks like that:
This produces an empty namespace in the "itemNo" node:

It should look like this:

I alread know that the key is to give the "nodel"-node the same namespace as the soapMethod, but I haven't found a way so far.
As you might have guessed, this is my first encounter with composing XML, so any help is appreciated.
I hope it's ok to post that problem here, because it might be related to using MSXML, which seems the only way to properly handle XML in the classic client.
I found some old code to consume a web service with C/AL, but it doesn't work. I suppose due to changes between MSXML versions.
The relevant part looks like that:
CREATE(xmldoc,TRUE,TRUE); // Create SOAP Envelope soapEnvelope := xmldoc.createElement('Soap:Envelope'); soapEnvelope.setAttribute('xmlns:Soap', 'http://schemas.xmlsoap.org/soap/envelope/'); xmldoc.appendChild(soapEnvelope); // Create SOAP Body soapBody := xmldoc.createElement('Soap:Body'); soapEnvelope.appendChild(soapBody); // Create Method Element soapMethod := xmldoc.createElement(method); soapMethod.setAttribute('xmlns', nameSpace); soapBody.appendChild(soapMethod); // Transfer parameters by loading them into a XML Document and move them CREATE(parametersXmlDoc,TRUE,TRUE); parametersXmlDoc.loadXML('<parameters>'+parameters+'</parameters>'); IF parametersXmlDoc.firstChild.hasChildNodes THEN BEGIN WHILE parametersXmlDoc.firstChild.childNodes.length>0 DO BEGIN nodel := parametersXmlDoc.firstChild.firstChild; nodel := parametersXmlDoc.firstChild.removeChild(nodel); soapMethod.appendChild(nodel); soapMethod.appendChild(nodel); END; END;
This produces an empty namespace in the "itemNo" node:

It should look like this:

I alread know that the key is to give the "nodel"-node the same namespace as the soapMethod, but I haven't found a way so far.
As you might have guessed, this is my first encounter with composing XML, so any help is appreciated.
0
Comments
-
Hi,
I would suggest to use XMLport to import/export xml file from NAV. its easiest way.
0 -
Thanks, but I would like to avoid that. However, I managed to get it working:
IF parameterXMLDoc.firstChild.hasChildNodes THEN BEGIN WHILE parameterXMLDoc.firstChild.childNodes.length > 0 DO BEGIN NewNode := parameterXMLDoc2.createNode(1,parameterXMLDoc.firstChild.firstChild.nodeName,nameSpace); //Parametername NewNode2 := parameterXMLDoc.firstChild.firstChild.firstChild; //Parameterwert NewNode2 := NewNode.appendChild(NewNode2); soapMethod.appendChild(NewNode); deletedNode := parameterXMLDoc.firstChild.firstChild; deletedNode := parameterXMLDoc.firstChild.removeChild(deletedNode); END; END;
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions