Web Services Error: Unable to Cast NavInteger to NavCode

csink
Member Posts: 4
Hi All,
We're running NAV 2009 SP1 with LSRetail. I'm working on some website integration to do item lookups. We're using VB.net. I've published the "Retail Item Card" web service through the NAV RTC. I've added a web reference to it and called it "RetailItemCard". A snippit of my code is below:
When I run this code, I get the following error when trying to use the "read" function:
Has anyone else run into this issue? Any suggestions?
Thanks for your help!
We're running NAV 2009 SP1 with LSRetail. I'm working on some website integration to do item lookups. We're using VB.net. I've published the "Retail Item Card" web service through the NAV RTC. I've added a web reference to it and called it "RetailItemCard". A snippit of my code is below:
Dim ICS As New RetailItemCard_Service Dim CRED As New System.Net.NetworkCredential("user", "XXXXX", "ourdomain.com") ICS.Credentials = CRED Dim IC As New RetailItemCard.RetailItemCard() IC = ICS.Read(0, "123123123") dim description as string description = IC.Description
When I run this code, I get the following error when trying to use the "read" function:
Server Error in '/' Application. -------------------------------------------------------------------------------- Unable to cast object of type 'Microsoft.Dynamics.Nav.Runtime.NavInteger' to type 'Microsoft.Dynamics.Nav.Runtime.NavCode'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.Services.Protocols.SoapException: Unable to cast object of type 'Microsoft.Dynamics.Nav.Runtime.NavInteger' to type 'Microsoft.Dynamics.Nav.Runtime.NavCode'. Source Error: Line 16: Line 17: IC = ICS.Read(0, No.Text) Line 18: dim description as string Line 19: description = IC.Description Source File: c:\inetpub\wwwroot\tools\nav\Default.aspx.vb Line: 17 Stack Trace: [SoapException: Unable to cast object of type 'Microsoft.Dynamics.Nav.Runtime.NavInteger' to type 'Microsoft.Dynamics.Nav.Runtime.NavCode'.] System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431766 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204 RetailItemCard.RetailItemCard_Service.Read(Int32 ShowStandardCard, String No) +85 Tools_NAV_Default.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\tools\nav\Default.aspx.vb:17 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Has anyone else run into this issue? Any suggestions?
Thanks for your help!

0
Comments
-
May be the definition of the webservice was changed since you have read the reference... :-k0
-
Hi,
Don't think so... I think the problem may have something to do with the "showstandardcard" (Integer) parameter on the "Read" method. The typical ItemCard reference does not have this parameter. I'm guess that it would take either 0 or 1 (0 = don't show standard card, 1 = show standard card) but perhaps my guess is wrong.
If there are any LSRetail folks reading this, perhaps you could shed some light on this parameter to help us out? (Since it seems like this is an LSRetail page, and not a standard NAV page).
Thanks for your suggestions!0 -
Hi All,
Problem Solved!!!
We found out that the extra parameter on the Retail Item Card (show standard card) was appearing in the web services because the on page 10000807 the Control ShowStandardCard was indented incorrectly. We corrected this, updated the web-reference, then the "showstandardcard" parameter disappeared! We had only the "No" (representing the Item No.) parameter available.
We recompiled and everything worked great!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