error accessing NAV 2013 Webservice using XML Ports

Erik_Heirbaut
Member Posts: 16
Hi everyone,
I try to use XMLPorts as Webservices, using a codeunit with global functions which I publish as a Webservice.
The response when entering the URL in IE or Chrome is not what I expected to get:
<s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">
a:Microsoft.Dynamics.Nav.Types.Exceptions.NavCSideException
</faultcode>
<faultstring xml:lang="nl-NL">
You must choose a company before you can access the "PSA920_App Resources Timesheet" table.
</faultstring>
<detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
You must choose a company before you can access the "PSA920_App Resources Timesheet" table.
</string>
</detail>
</s:Fault>
The same XMLPorts and Codeunit work fine in NAV 2009R2, but I get this error in NAV 2013 RTM build 34902.
Webservices working without XML Ports work fine, but as soons as there is one or more global function in the codeunit which uses an XMLPort, the error occurs.
The XMLPort itself works fine when I run it directly.
The tables used by the XMLPorts (as TEMPORARY) can be accessed without problems when I run them directly.
Neither the XMLPort, nor the codeunit, have compile errors.
The Codeunit consists of several functions that use XMLPorts, for instance:
RetrieveLeaveEntries(ResourceCode : Code[20];VAR XMLLeaveEntries : XMLport "PSA920_App Leave Entries")
// Available as Webservice
XMLLeaveEntries.SetParameters(ResourceCode);
IF NOT XMLLeaveEntries.EXPORT THEN
ERROR(TxcErrExportLaveEntries);
The URL is constructed as follows:
http://server:port/service/WS/company/Codeunit/Name
Does this sound familiar to anyone and what might solve this issue?
Thanks!
I try to use XMLPorts as Webservices, using a codeunit with global functions which I publish as a Webservice.
The response when entering the URL in IE or Chrome is not what I expected to get:
<s:Fault>
<faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">
a:Microsoft.Dynamics.Nav.Types.Exceptions.NavCSideException
</faultcode>
<faultstring xml:lang="nl-NL">
You must choose a company before you can access the "PSA920_App Resources Timesheet" table.
</faultstring>
<detail>
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
You must choose a company before you can access the "PSA920_App Resources Timesheet" table.
</string>
</detail>
</s:Fault>
The same XMLPorts and Codeunit work fine in NAV 2009R2, but I get this error in NAV 2013 RTM build 34902.
Webservices working without XML Ports work fine, but as soons as there is one or more global function in the codeunit which uses an XMLPort, the error occurs.
The XMLPort itself works fine when I run it directly.
The tables used by the XMLPorts (as TEMPORARY) can be accessed without problems when I run them directly.
Neither the XMLPort, nor the codeunit, have compile errors.
The Codeunit consists of several functions that use XMLPorts, for instance:
RetrieveLeaveEntries(ResourceCode : Code[20];VAR XMLLeaveEntries : XMLport "PSA920_App Leave Entries")
// Available as Webservice
XMLLeaveEntries.SetParameters(ResourceCode);
IF NOT XMLLeaveEntries.EXPORT THEN
ERROR(TxcErrExportLaveEntries);
The URL is constructed as follows:
http://server:port/service/WS/company/Codeunit/Name
Does this sound familiar to anyone and what might solve this issue?
Thanks!
0
Answers
-
I guess you have written code to Get the PSA920_App Resources Timesheet table in OnInitXMLport trigger like
PSA920AppResourcesTimesheet.GET;
Please move the code from OnInitXMLport trigger to OnPreXMLport trigger and try0 -
This was indeed the solution: Data access in OnInitXMLPort seems to be forbidden.
The compiler does not warn for it...
=D> =D>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