How to create webservice question

donitdonit Member Posts: 24
edited 2012-07-17 in NAV Three Tier
Hi,
It’s NAV 2009 6 but still Classic Client. I’d need to create a webservice to enter/modify/delete data in a Contact and Contact Mailing Group tables from a web page. The web page will have a person name, email, and mail group codes that match with NAV entries. I’ve read the following nice articles
http://www.kauffmann.nl/blog/index.php/ ... ervices-1/
and others and it seems as it shouldn’t be that difficult to create a codeunit with INSERT, MODIFY, DELETE statements and register it as a webservice. The codeunit however should return an integer only to a web page to show a transaction success, e.g. EXIT(1). If I need to return a table data then I’d use a root element then a table element then a field element, etc. But, I’m wondering if I need to return an integer only then how the XMLPort could look like or I could possibly use some different approach for it not an XMLPort.

Probably, I don't need an XMLPort at all as I could use a codeunit with a function and parameters. I'd register this codeunit as a webservice and refer to a method from a webpage passing parameters.

Thanks

Comments

  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    donit wrote:
    Hi,
    I could use a codeunit with a function and parameters. I'd register this codeunit as a webservice and refer to a method from a webpage passing parameters.
    Thanks

    I would use this approach...
    ~Rik~
    It works as expected... More or Less...
  • donitdonit Member Posts: 24
    donit wrote:
    Hi,
    I could use a codeunit with a function and parameters. I'd register this codeunit as a webservice and refer to a method from a webpage passing parameters.
    Thanks

    I would use this approach...

    Thank you so much. I cannot find a button as on other forumes to mark the answer as a solution.

    Please, also advise if you know I'm going to create a simple code using a gloabal record variable using IF .. .GET THEN EXIT(-1) // meaning already exists returning the -1 to a webpage
    otherwise INSERT(TRUE) EXIT(1) //meaning entered returning the 1 to a webpage
    for the Contact table and then for the contact Mailing Group.

    Should I do any other validations in the function?

    Or it'd be better to copy a code from the tables triggers? But I don't probably have access due to a license.
  • mihail_kolevmihail_kolev Member Posts: 379
    You don't need to use IF GET THEN EXIT(-1). The INSERT function also return boolean ;)
    Trigger validations should work just fine.
    -Mihail- [MCTS]
  • donitdonit Member Posts: 24
    You don't need to use IF GET THEN EXIT(-1). The INSERT function also return boolean ;)
    Trigger validations should work just fine.

    Thank you so much for your response, Mihail.
Sign In or Register to comment.