Options

[.NET] Access WebService

kizinkizin Member Posts: 18
edited 2009-03-14 in NAV Three Tier
Hello,

I'm trying to connect a Nav 2009 Web services.

I've found some code example on the Internet :
private void button1_Click(object sender, EventArgs e)
        {
            NavWSAchat.WSAchat_Service service = new NavWSAchat.WSAchat_Service();
            service.UseDefaultCredentials = true;
            
            //service.Url = "http://localhost:7047/DynamicsNAV/WS/Page/WSAchat";

            NavWSAchat.WSAchat achat = new NavWSAchat.WSAchat();

            //creation du filtre
            List<NavWSAchat.WSAchat_Filter> filterList = new List<NavWSAchat.WSAchat_Filter>();
            NavWSAchat.WSAchat_Filter noFilter = new NavWSAchat.WSAchat_Filter();

            noFilter.Field = NavWSAchat.WSAchat_Fields.No;
            noFilter.Criteria = RechercheTextBox.Text;
            filterList.Add(noFilter);

            NavWSAchat.WSAchat[] AchatList = service.ReadMultiple(filterList.ToArray(), null, 100);
            DataTable dt = CreateAchatTable();
            DataRow row;

            foreach (NavWSAchat.WSAchat achatItem in AchatList)
            {
                //Création de DataTable et DataRow
                row = dt.NewRow();

                row["No"] = achatItem.No;
                row["Status"] = achatItem.Status;

                row["Responsibility_Center"] = achatItem.Responsibility_Center;

                dt.Rows.Add(row);
            }

on the line :
NavWSAchat.WSAchat[] AchatList = service.ReadMultiple(filterList.ToArray(), null, 100);
I got an error : You must define Path Property before calling Send Method


if I uncomment the line :
service.Url = "http://localhost:7047/DynamicsNAV/WS/Page/WSAchat";
I got an error : The supplied Company Name is not valid

So I try :
service.Url = "http://localhost:7047/DynamicsNAV/WS/CRONUS_FRANCE_S_A/Page/WSAchat";
I got an error : The supplied Company Name is not valid


Which company name have I to put? It is the French version of Navision.


Thanks,

Yann

Answers

  • Options
    freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    What is the company name in France (without name mangling)?
    (then I can mangle the name for you)

    Else there is a function called Companies which can found in the SystemService:

    http://localhost:7047/DynamicsNAV/WS/SystemService
    In that one you should get a list of the companies using the following code:
    SystemService svc = new SystemService();
    svc.UseDefaultCredentials = true;
    foreach (string company in svc.Companies())
    {
         MessageBox.Show(company);
    }
    

    But.... - I just found out that you need to have the company in the path to call that function too - I see that as a bug.

    So - what is the name of french Cronus?
    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.
  • Options
    kizinkizin Member Posts: 18
    The name is "Cronus France S.A."

    I'll try your piece of code tomorrow.

    thx for the reply.

    Yann
  • Options
    freddy.dkfreddy.dk Member, Microsoft Employee Posts: 360
    Your name mangling looks correct - but it is Case Sensitive.

    Cronus_France_S_A

    should be right - if CRONUS indeed isn't capitalized.
    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.
  • Options
    kizinkizin Member Posts: 18
    I tried this morning.

    Effectively, it is case sensitive... and it was my problem.

    thanks a lot

    Yann
  • Options
    nicochinenicochine Member Posts: 1
    Hello,

    I have exactly the same problem as you with the company "CRONUS France S.A.". Did you find the correct writing for the URL ?

    I'm trying to add web reference in visual studio 2008 but i can't.

    Thank you for your help.
Sign In or Register to comment.