Web Service (Code Uint Problem)

yukonyukon Member Posts: 361
edited 2010-06-22 in NAV Three Tier
Hi All,

Now i'm trying web service. NAV2009 web service support 2 types. 1 is page and code unit. When i test code unit web service i got error.

My test case :

1. Create function in new code unit.
2. Declare public GetCrossRef function.
3. Declare parameter at GetCrossRef function.
3.1 parCrossRef (Code20)
3.2 recSalesLine (Record Sales Line)
3.3 item (Code20 for return)
4. Register Web Service
4.1 Code Unit 50000 GetCrossRefs

5. http://localhost:7047/DynamicsNAV/WS/Co ... tCrossRefs.


Ok! When i type above url address at browser. Nothing come out. So i remove Sales Line parameter it is work.

Why does not support record parameter at code unit web service? Anybody have face this error?

How to use/call with record parameter at code unit web service?
Kindly please suggest to me.

Best Regards,
Yukon
Make Simple & Easy

Comments

  • AdrianAkersAdrianAkers Member Posts: 137
    You can't pass variables of type record in a codeunit via the webservices as this is a complex type which is not supported. You shouldn't need to pass records around... We have all the tools at our disposal...
  • kinekine Member Posts: 12,562
    You can, but than you need to not check the "publish" field for the codeunit in the webservice table, and than you will see the function as part of the Page webservice. In this way you can use this function over the record... just study the documentation... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AdrianAkersAdrianAkers Member Posts: 137
    Yeah sure you can publish a page or a codeunit as a webservice, but neither of them are a record variable. A page is much more than this. You can not call a function in an exposed codeunit where the function contains a parameter variable of type record.
  • kinekine Member Posts: 12,562
    Yeah sure you can publish a page or a codeunit as a webservice, but neither of them are a record variable. A page is much more than this. You can not call a function in an exposed codeunit where the function contains a parameter variable of type record.
    I want to tell you that you CAN. But you need to not check the "Publish" field in the webservice for the codeunit and the codeunit Webservice must have same name as the page. In this case, the codeunit functions will be connected to the page webservice and you can use the first parameter of the functions with type record with same subtype as page, to pass the record to the functions... just study this case...

    Official documentation for this: http://msdn.microsoft.com/en-us/library/dd338962.aspx
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • AdrianAkersAdrianAkers Member Posts: 137
    I know this already, but thanks :roll: Perhaps we aren't talking about the same thing. In the example on the link you gave the C# code at no point passes in a variable of type record to the function exposed in NAV. Instead it passes in a reference to the primary key of the record and NAV handles that internally... I see many posts on here where people want to declare a parameter in a function as type record and then they want to pass that record type from C#, vb.NET or whatever. Let's not confuse the issue. So in the C# code we have,
    service.CapitalizeName(cust.Key);
    // Refresh customer.
    cust = service.Read(cust.No);
    
    What we don't have is :-
    service.CapitalizeName(ref cust);
    

    An example of people trying to do just that appeared on this post;
    1. Create function in new code unit.
    2. Declare public GetCrossRef function.
    3. Declare parameter at GetCrossRef function.
    3.1 parCrossRef (Code20)
    3.2 recSalesLine (Record Sales Line)
    3.3 item (Code20 for return)
    4. Register Web Service
    4.1 Code Unit 50000 GetCrossRefs

    I just want us to to be clear...

    On a separate note we are supporting 550+ web users (using an ASP.net front end) across the middle tiers using the NAV web services in SP1 quite happily... :thumbsup:
  • AdrianAkersAdrianAkers Member Posts: 137
    PS: The Microsoft example is a good way to use A LOT of codeunits in your solutions! :D
Sign In or Register to comment.