How to consume an external web service from Navision

bultelabultela Member Posts: 6
edited 2014-07-18 in NAV Three Tier
Hello all,

May I ask you a question concerning invoking external web services ?

I read in Mr Ernst 's blog the possibility to invoke an external web service from Navision :
<<
Here is a link to a blog post about connecting to SOAP Web Services from inside NAV:
http://navcode.blogspot.dk/2012/01/conn ... -from.html
>>
Can you please tell me if this works also in NAV 2013 R2 ? (as automation variables are used)
and if not do I have to develop it in DOTNET ?

I have already read relevant MSDN help for NAV 2013 R2 but the external web service to consume has not been done with a proxy class (contrary to MSDN Help)

Note also that the web service to call has to export data from a table and not to import it.

I don't know which syntax to use to export data.


I would really appreciate an answer from you.

Thanks for your reply

abultel

Comments

  • thegunzothegunzo Member Posts: 274
    You can read some here
    http://www.dynamics.is/index.php?tag=web-services
    
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • james_csjames_cs Member Posts: 39
    The easiest way to consume web services these days is to create a DotNet Wrapper and drop it into the AddIns folder. This is a small piece of .net code that consumes the web service and parses the results out in a series of functions that NAV can understand.

    There is no problem using server-side Dot-Nets as they only have to be installed on the server and not on the client and they do not have to be registered in the Client add-ins table

    This is an example of one I wrote to talk to a free SOAP service that returns exchange rate information
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Evosoft.DynamicsNAV.CurrencyWS
    {
        public class CurrencyWS
        {
            private FXConverter.Currency StringToCurrency(string CurrCode)
            {
                FXConverter.Currency Currency = new FXConverter.Currency();
                for (int i = 0; i <= Enum.GetNames(typeof(FXConverter.Currency)).Length; i++)
                {
                    Currency = (FXConverter.Currency)i;
                    if (Currency.ToString() == CurrCode)
                    {
                        return (Currency);
                    }
                }
                return (0);
    
            }
            public Double ExchangeRate(string FromISOCurrCode, string ToISOCurrCode)
            {
                FXConverter.Currency FromCurrency = StringToCurrency(FromISOCurrCode);
                FXConverter.Currency ToCurrency = StringToCurrency(ToISOCurrCode);
                FXConverter.CurrencyConvertor WS = new FXConverter.CurrencyConvertor();
                return(WS.ConversionRate(FromCurrency,ToCurrency));
            }
    
        }
    }
    
  • bultelabultela Member Posts: 6
    Hello James,

    First, thank you for your answer.

    But as I am not a Dotnet developper, I would like to understand a bit more your example.

    When you say that "the small piece of .net code consumes the web service and parses the results out in a series of functions that NAV can understand" ; can you please explain me in your example where is the interface to Navision ?

    Where are in your code the series of functions that can be understood by navision ?
    How is done the call from navision ?

    My goal is to call an existing web service with an argument and export a list of records from a navision table.

    Thanks for your reply

    Arnaud
  • MHavemannMHavemann Member Posts: 10
    Hello Arnaud

    Try using the link Gunnar poste din his answer. I did not and allthough I am not a DotNet developer either, I had the code up and working in NAV in 15 minutes by following his guide.
  • saravanans87saravanans87 Member Posts: 36
Sign In or Register to comment.