[solved]How can I run command of an external webservice

massimopasqualimassimopasquali Member Posts: 82
edited 2016-11-08 in NAV Three Tier
Hello,

I'm developing NAV2013.

I need to import data from an extenal management program, to do that I have to run "C" or "Java" command from C/AL sentences program. How can I do that?

Now I'm using to developing Visual studio, by "webreference" I can to export from NAV to online, but now I have to do the opposite thing, from an external Webservice I have to import data in NAV to running in C/AL sentence the commands of this webservice management program not NAV

thanks.

Answers

  • kinekine Member Posts: 12,562
    There is more ways. You can create dotnet wrapper and use it through DotNet interop, or use XMLDom to create and send the SOAP request and process the response, or you can use something what Vjeko already published, framework which using DotNet functionality can call the webservices from outside (through reflection and other magic...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • tarkmylertarkmyler Member Posts: 57
    1. Create a C# wrapper for the web service that you can reference inside of C/Side. C# > New Project > Class Library
    2. You can delete the default class.
    3. Add the Web Service: Service References > Add Service Reference > Advanced > Add Web Reference > [enter url and name the reference ] > build project > insert into Add-Ins folder.
    4. In C/Side report/codeunit add .NET variable references - see sample below:

    Name DataType Subtype
    XYZ_OrderService DotNet XYZWebService.OrderService.blah blah
    XYZ_Security DotNet XYZWebService.OrderService.Security.blah blah

    //>>Instantiate Web Service
    XYZ_OrderService := XYZ_OrderService.OrderServiceService(); //Declare Constructor

    //>>Security
    XYZ_Security := XYZ_Security.Security(); //Declare Constructor
    XYZ_Security.Password := XYZ_Setup."Service Password";
    XYZ_Security.Username := XYZ_Setup."Service UserName";

    etc. ad infinitum
    Mark Tyler
    Pacific City, OR
  • massimopasqualimassimopasquali Member Posts: 82
    thanks
Sign In or Register to comment.