SOAP request to NAV codeunit webservice

thmartin
Member Posts: 90
I have one database in which I run an XMLPort that creates the following XML and send it via http request to a NAV Webservice in an other database.
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateC xmlns="urn:microsoft-dynamics-schemas/codeunit/CWSMgt">
<importdata>
<CHead>
<No>4</No>
<Title>4 Test</Title>
<Date>10.12.13</Date>
<Author>JR</Author>
<TNo>T12345</TNo>
</CHead>
</importdata>
</UpdateC>
</soap:Body>
</soap:Envelope>
In the other databse I have published codeunit CWSMgt as a web service.
This codeunit has a function UpdateC with a parameter called importdata.
First I tried to use an XMLPort as the parameter.
The error that I am getting here is like that:
a:Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLXmlPortInvalidXmlExceptionImported XML cannot validate with the schema: The element 'importdata' has an invalid child Element 'CHead' in Namespace 'urn:microsoft-dynamics-schemas/codeunit/CIDWSMgt'. Expected was the list of possible elements: 'CHead'.
If I alternatively use a BigText as the parameter I seem to get only the node values. But that doesn't seem to be XML anymore. The tags are missing.
UpdateC(importdata : BigText) : Text[1024]
TempBlob.Blob.CREATEOUTSTREAM(loutstr);
importdata.WRITE(loutstr);
TempBlob.CALCFIELDS(Blob);
TempBlob.Blob.EXPORT('C:\Temp\blob.txt');
The file looks like:
4 4 Test 10.12.13 T12345
Any hints on how to overcome the namespace problem or the lost XML formatting in the text variable?
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateC xmlns="urn:microsoft-dynamics-schemas/codeunit/CWSMgt">
<importdata>
<CHead>
<No>4</No>
<Title>4 Test</Title>
<Date>10.12.13</Date>
<Author>JR</Author>
<TNo>T12345</TNo>
</CHead>
</importdata>
</UpdateC>
</soap:Body>
</soap:Envelope>
In the other databse I have published codeunit CWSMgt as a web service.
This codeunit has a function UpdateC with a parameter called importdata.
First I tried to use an XMLPort as the parameter.
The error that I am getting here is like that:
a:Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLXmlPortInvalidXmlExceptionImported XML cannot validate with the schema: The element 'importdata' has an invalid child Element 'CHead' in Namespace 'urn:microsoft-dynamics-schemas/codeunit/CIDWSMgt'. Expected was the list of possible elements: 'CHead'.
If I alternatively use a BigText as the parameter I seem to get only the node values. But that doesn't seem to be XML anymore. The tags are missing.
UpdateC(importdata : BigText) : Text[1024]
TempBlob.Blob.CREATEOUTSTREAM(loutstr);
importdata.WRITE(loutstr);
TempBlob.CALCFIELDS(Blob);
TempBlob.Blob.EXPORT('C:\Temp\blob.txt');
The file looks like:
4 4 Test 10.12.13 T12345
Any hints on how to overcome the namespace problem or the lost XML formatting in the text variable?
Thomas Martin
NAV Developer
NAV Developer
0
Comments
-
I got it. I had to set the UseDefaultNameSpace property in the importing XMLPort to Yes. I only had set the DefaultNameSpace property.Thomas Martin
NAV Developer0
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