Web Services Error: Unable to Cast NavInteger to NavCode

csinkcsink Member Posts: 4
edited 2009-09-25 in NAV Three Tier
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:
        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! :)

Comments

  • kinekine Member Posts: 12,562
    May be the definition of the webservice was changed since you have read the reference... :-k
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • csinkcsink Member Posts: 4
    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!
  • csinkcsink Member Posts: 4
    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! :)
Sign In or Register to comment.