Web service using extension codeunit - Still need help

maris2000maris2000 Member Posts: 71
edited 2009-04-14 in NAV Three Tier
I have made a nav web service with extension codeunit, but I can not see the methods of the extension codeunit when I call it from .net.
I have verified the web service availability, and tested the service in .net before I added the extension codeunit and it worked fine.
The code unit calls XMLPort and and saves a XML file to the users hard drive.
Any suggestions on this issue? :cry: Please help

Answers

  • maris2000maris2000 Member Posts: 71
    I have added a new method to my codeunit and I can call it form .net app.
    But why can't I see the method that should create XML?
    I am little bit confused now.
    How else can I create this XML file and save it on users computer?
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    I am not sure that I understand what you are trying to accomplish.
    Web Services runs on the service tier and there is no way you would be able to save something on the users computer from the service tier - that would be something you would do in the application in which you invoke the web service.
    Also I am not sure what you mean by extension codeunit - you publish codeunits to web services through the webservice table and you "see" them in the WSDL - is this where you don't see some of the methods?
    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.
  • PutxiPutxi Member Posts: 8
    The Cu name in form 810 must have the same name than the page you want to extent and the cu publisher check box must be cleared.
  • maris2000maris2000 Member Posts: 71
    edited 2009-04-09
    I'll try to explain myself a little bit better.
    I need to export some data from a Navision table to MS Access table.
    NAV 2009 SQL Classic Client is hosted and Access db is installed on the user's computer.
    I have created web service and extended the default set of methods with a codeunit. (published codeunit to the web services through the webservice table)
    I am Navision newbie so I sick to the terms from the documentation. The term "extension codeunit" comes from Microsoft Web Services Launch:
    The walkthrough illustrates how to publish a page with an extension codeunit as a Web service and use this published Web service from a console application. Adding an extension codeunit to a page is useful if you want to perform operations other than CRUD (create, read, update, and delete) operations on data.
    My codeunit creates XML file of the data I need. I have done this by creating XMLPort and then adding the following function to my codeunit
    ExportItems()
    
    IF EXISTS('C:\XML_Item.xml') THEN
      ERASE('C:\XML_Item.xml');
    
    TestFile.CREATE('C:\XML_Item.xml');
    TestFile.CREATEOUTSTREAM(TestStream);
    XMLPORT.EXPORT(50010, TestStream);
    TestFile.CLOSE;
    
    In .net part I have created an app in which I invoke the web service. I can access all the methods of the except mine "ExportItems", and this means that it is not present in WSDL file either.
    I have added a few other functions to the same codeuinit and I can access them no problem.
  • maris2000maris2000 Member Posts: 71
    Putxi wrote:
    The Cu name in form 810 must have the same name than the page you want to extent and the cu publisher check box must be cleared.

    The codeunit and the web service have the same name and codeunit check box is cleared. This part I know, but there is something wrong with XML part
  • freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    First of all, the functions exposed are the functions, where the first parameter is a Record type of the same Record as the page in which you expose the function.
    Your ExportItems doesn't have any parameters and won't be exposed.

    Secondly - note that your function tries to save something on the C:\ drive of the service tier - NOT the client tier.
    The WebService function cannot reach the Client tier - as it is on a different machine and it probably doesn't have sufficient rights to write in the root folder of the C: drive on the service tier.

    What you need to do is to have a function that returns your XML port as XML and then you can use it in the function that calls the webservice method.
    There are a number of samples on how to do this on my blog.

    Hope that helps
    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.
  • maris2000maris2000 Member Posts: 71
    Hi Freddy,

    Thank you loads for the answer and your wonderful blog.
    Thank you one more time for sharing your knowledge =D>
Sign In or Register to comment.