Webservice issues (multiple)

Miklos_HollenderMiklos_Hollender Member Posts: 1,598
edited 2009-03-10 in NAV Three Tier
I'm messing with a codeunit-based web service, managed to get to this stage:
  <faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Types.Exceptions.NavNCLMetadataFailedException</faultcode> 
  <faultstring xml:lang="en-GB">Metadata for object of type CodeUnit with id 50000 is in a failed state. This is caused by a previous exception: Could not find a part of the path 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit50000.cs'.</faultstring> 
- <detail>
  <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Metadata for object of type CodeUnit with id 50000 is in a failed state. This is caused by a previous exception: Could not find a part of the path 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source\Codeunit\Codeunit50000.cs'.</string> 

(This is in the WSDL page opened in the browser).

I've recompiled, republished, restarted both services, still the same... any ideas?

I got this point by trying to somehow be able to return strings longer than 1024 chars from the webservice codeunit. So I was trying stuff like using a VAR parameter of a BigText type (as a return type cannot be a BigText) and other similar tricks and it just happened. Restoring it to the original (the capitalize example) and recompile/republish/restart didn't help.

Which brings us to the second topic - what's the best way to return more than 1024 chars? I think the VAR parameter of BigText type sounds promising, but perhaps that's what broke it.

Comments

  • ara3nara3n Member Posts: 9,255
    The error you are seeing actually comes from service tier. The WebService windows service communicates with NavServer. So for some reason your Codeunit is not translated into c sharp and so service tier does not have the codeunit.

    As far passing strings longer than 1024, yes you can use bigtext as parameter and pass it by reference (VAR).

    Webservice will return the parameter back to the caller.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ara3nara3n Member Posts: 9,255
    You should try and restart the Service tier. Also delete all the records from Object Tracking table first and then restart the Navservice and Nav WebService
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    http://blogs.msdn.com/freddyk/archive/2008/11/23/search-in-nav-2009-part-1-out-of-3.aspxcontains an example on how to return a large string trough a web service.
    Freddy Kristiansen
    Group Program Manager, Client
    Microsoft Dynamics NAV
    http://blogs.msdn.com/freddyk

    The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
  • Tom_CorneliusTom_Cornelius Member, Microsoft Employee Posts: 18
    There is a key in the customsettings.config file called WebServicesMaxMsgSize. It is actually a WCF setting. By default it is set to 512k. Increasing this and restarting the service should allow a larger data packet to be sent.
    Tom Cornelius
    Test Lead
    Microsoft Dynamics NAV

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    I fixed it, but I don't exactly know how. Point is, I didn't have a MicrosoftDynamicsNavServer directory under the C:\ProgramData\Microsoft\Microsoft Dynamics NAV\60\Server.

    Now, I've restarted both services a couple of times, using the normal "Restart" menu item, but what happened now that I stopped both fully. And then I just started the NAV Service but not the Business WebService. And it created these directories.

    Although I never seen a .cs file in them, even though I modified and recompiled the codeunit, it started to work. Interesting.

    My guess is that the MicrosoftDynamicsNavServer subdirectory and all those under it in ProgramData are deleted at some point and a simple restart of the server service does not recreate it, perhaps because the business webservice service is running too. Stopping both and starting the nav service recreates it. Strange.
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Oh! I just fund that if I use an XMLPort as a VAR parameter to pass stuff back to the code that called the webservice, like in http://blogs.msdn.com/freddyk/archive/2 ... stuff.aspx

    I can't pass that XMLPort on to another function as yet another VAR Parameter to construct it in that function, it has to be constructed in the original one, because it says assignment is not allowed.

    That's not very handy when there are 50 little functions in the web service that I intendeded to write as one-liners, calling one general function with different parameters... :-/
  • ara3nara3n Member Posts: 9,255
    You should use BigText as parameter and stream it into a local variable xmlport.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    ara3n wrote:
    You should use BigText as parameter and stream it into a local variable xmlport.

    Hand-writing all the XML's?... Oh... wait, I think I know what you mean. Function 1 is exposed to the web service with a ByRef XMLPort. It calls Function 2 giving a BigText ByRef parameter. Function 2 calls Function 3 giving in the same BigText the same way. Function 3 instantiates an XMLPort, streams it into the BigText, and it goes all the way back to Function 1 which streams the BigText back into the XMLPort. OK, I think that can be done. I think I should try it and blog it :)
  • Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Correction: it must be a temptable on the TempBlog record: - BigText cannot CREATEOUTSTREAM.
Sign In or Register to comment.