Web services in nav R2

rhardoyalrhardoyal Member Posts: 78
edited 2012-02-15 in NAV Three Tier
Hi,

Any one has any example of how to use web services in navision R2. Please help on this.

Thanks
Rizwana

Answers

  • WaldoWaldo Member Posts: 3,412
    :-k

    I clicked the URL .. and I do think there are much better examples .. not to say that the URL above isn't a NAV 2009 example (2009 isn't even mentioned in the article). Or am I dreaming? :-)

    Here are some of mine:
    - http://dynamicsuser.net/blogs/waldo/arc ... rvice.aspx
    - http://dynamicsuser.net/blogs/waldo/arc ... rvice.aspx

    There are lots of examples on Freddy's blog. here is one:
    - http://blogs.msdn.com/b/freddyk/archive ... again.aspx

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ChowdaryChowdary Member Posts: 148
    Waldo wrote:
    :-k

    I clicked the URL .. and I do think there are much better examples .. not to say that the URL above isn't a NAV 2009 example (2009 isn't even mentioned in the article). Or am I dreaming? :-)

    Here are some of mine:
    - http://dynamicsuser.net/blogs/waldo/arc ... rvice.aspx
    - http://dynamicsuser.net/blogs/waldo/arc ... rvice.aspx

    There are lots of examples on Freddy's blog. here is one:
    - http://blogs.msdn.com/b/freddyk/archive ... again.aspx

    Hi Waldo

    when I try to use

    http://localhost:7047/DynamicsNAV/WS/Services

    I'm getting error,
    Internet Explorer can not display the webpage ](*,)

    what am I doing wrong here ?

    Thanks in advance

    Chowdary
    Pleasure in the job puts perfection in the work
  • WaldoWaldo Member Posts: 3,412
    Are your web services running ("business webservices" in your services window..)?
    If you restart, you can find a url in the event viewer where you can find the web services. Does it deviate of the url you're trying to use?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ChowdaryChowdary Member Posts: 148
    Waldo wrote:
    Are your web services running ("business webservices" in your services window..)?
    If you restart, you can find a url in the event viewer where you can find the web services. Does it deviate of the url you're trying to use?

    Oops !!
    you are right, web services stopped.
    Thanks waldo. It's okay now

    Chowdary
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    Hi Waldo

    I can not see Visual C# on my Visual Studio window.( that you show on your blog)
    Do I have to install other s/w ?

    Thanks in advance
    Chowdary
    Pleasure in the job puts perfection in the work
  • julkifli33julkifli33 Member Posts: 1,091
    does anyone know or have the sample which we can send parameter as to open company name?
    because i have case, i'm using 1 database with several companies....
    each txt file for each company.... so i must import the txt file or different company
  • WaldoWaldo Member Posts: 3,412
    Chowdary wrote:
    Hi Waldo

    I can not see Visual C# on my Visual Studio window.( that you show on your blog)
    Do I have to install other s/w ?

    Thanks in advance
    Chowdary

    Did you install it while installing Visual Studio? :)

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • ChowdaryChowdary Member Posts: 148
    Waldo wrote:
    Chowdary wrote:
    Hi Waldo

    I can not see Visual C# on my Visual Studio window.( that you show on your blog)
    Do I have to install other s/w ?

    Thanks in advance
    Chowdary

    Did you install it while installing Visual Studio? :)

    what is it. I mean, what software ?

    BTW, I have installed Microsoft visual c# 2008 express edition yesterday with no luck to see Visual C# node.

    Plz help me out ](*,)

    Thanks
    Chowdary
    Pleasure in the job puts perfection in the work
  • DuikmeesterDuikmeester Member Posts: 307
    julkifli33 wrote:
    does anyone know or have the sample which we can send parameter as to open company name?
    because i have case, i'm using 1 database with several companies....
    each txt file for each company.... so i must import the txt file or different company

    The company that you open is the one that you use in the URL of the web-service for example:

    http://localhost:7047/DynamicsNAV/WS/Re ... on_Service

    See it says "ReplaceWithAPercentEncodedCompanyName".
  • ChowdaryChowdary Member Posts: 148
    Chowdary wrote:
    Waldo wrote:
    Chowdary wrote:
    Hi Waldo

    I can not see Visual C# on my Visual Studio window.( that you show on your blog)
    Do I have to install other s/w ?

    Thanks in advance
    Chowdary

    Did you install it while installing Visual Studio? :)

    what is it. I mean, what software ?

    BTW, I have installed Microsoft visual c# 2008 express edition yesterday with no luck to see Visual C# node.

    Plz help me out ](*,)

    Thanks
    Chowdary

    =D>
    I managed to see Visual C# node, after installing Visual Studio 2010.
    Pleasure in the job puts perfection in the work
  • ChowdaryChowdary Member Posts: 148
    One more issue came up :x

    when I browse service using
    http://localhost:7047/DynamicsNAV/WS/Services
    I saw xml code.

    but when I'm trying with company name
    http://localhost:7047/DynamicsNAV/WS/CR ... d/Services

    am getting http 500 internal error.

    Even log showing:
    Service "CRONUS International Ltd/Services/_vti_bin/ListData.svc/$metadata" was not found!

    any idea :-k

    Thanks
    Chowdary
    Pleasure in the job puts perfection in the work
  • deV.chdeV.ch Member Posts: 543
    Since this is an url you ened to encode it. The Company name has white spaces in it's name so you need to replace them with %20, or simply call the method
    System.Web.HttpUtility.UrlPathEncode() (http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx)
  • ChowdaryChowdary Member Posts: 148
    deV.ch wrote:
    Since this is an url you ened to encode it. The Company name has white spaces in it's name so you need to replace them with %20, or simply call the method
    System.Web.HttpUtility.UrlPathEncode() (http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx)

    deV thanks for the response

    Actually I'm using %20, if not me IE assigning space with %20.
    So, that's not a problem.

    Today, my web server is not responding. I mean if I run with http://localhost am getting error.
    An error has occurred.

    Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
    I have installed visual Studio 2010 today, is that causing problem?

    am searching forums to find out why http://localhost is not running, but cannot find my answer.

    any ideas would be greatly appreciated.

    Thanks
    Chowdary
    Pleasure in the job puts perfection in the work
  • julkifli33julkifli33 Member Posts: 1,091
    julkifli33 wrote:
    does anyone know or have the sample which we can send parameter as to open company name?
    because i have case, i'm using 1 database with several companies....
    each txt file for each company.... so i must import the txt file or different company

    The company that you open is the one that you use in the URL of the web-service for example:

    http://localhost:7047/DynamicsNAV/WS/Re ... on_Service

    See it says "ReplaceWithAPercentEncodedCompanyName".
    deV.ch wrote:
    Since this is an url you ened to encode it. The Company name has white spaces in it's name so you need to replace them with %20, or simply call the method
    System.Web.HttpUtility.UrlPathEncode() (http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx)

    so can i create 1 C# form.... to execute all these companies???
    or should I create as many as companies?
    lets say now i have 5 companies, but how if there are 2 more companies in the future?
    should i create another c# web services?
    thanks
  • deV.chdeV.ch Member Posts: 543
    Nope the service doesn't change if you add a company. It just responds on the new URL. It's pritty simple you just need to replace the hardcoded URL with a dynamic like:
    string EncodedCompanyName = System.Web.HttpUtility.UrlPathEncode(CompanyName);
    string WSUrl = string.Format("http://localhost:7047/DynamicsNAV/WS/{0}/Codeunit/Integration_Service",EncodedComapanyName);
    

    On your C# Form you add a dropdown list, that shows all companys (If you not already know, there is a system service that returns you a list of all companies).
  • chethanhtchethanht Member Posts: 14
    If http://localhost is not working, this is not the right forum.
  • julkifli33julkifli33 Member Posts: 1,091
    deV.ch wrote:
    Nope the service doesn't change if you add a company. It just responds on the new URL. It's pritty simple you just need to replace the hardcoded URL with a dynamic like:
    string EncodedCompanyName = System.Web.HttpUtility.UrlPathEncode(CompanyName);
    string WSUrl = string.Format("http://localhost:7047/DynamicsNAV/WS/{0}/Codeunit/Integration_Service",EncodedComapanyName);
    

    On your C# Form you add a dropdown list, that shows all companys (If you not already know, there is a system service that returns you a list of all companies).

    does anyone know how to drop down company?
  • julkifli33julkifli33 Member Posts: 1,091
    if i created import data using report
    can we automate it using web service (windows scheduler) ?
    thanks
  • yukonyukon Member Posts: 361
    Hi julkifli33,
    julkifli33 wrote:
    if i created import data using report
    can we automate it using web service (windows scheduler) ?
    thanks

    My understanding you want to call your program from Window Schedule? Am i right?
    For my view is "Yes".

    1. Write Simple prorgam (c#)
    2. Window Schedule Call to ur prog.
    3. Public CU (in NAV)
    4. CU call to your import rpt. (in NAV).

    I hope someone can give to you best ans. That is from my point :)

    Regards,
    Yukon
    Make Simple & Easy
  • julkifli33julkifli33 Member Posts: 1,091
    yukon wrote:
    Hi julkifli33,
    julkifli33 wrote:
    if i created import data using report
    can we automate it using web service (windows scheduler) ?
    thanks

    My understanding you want to call your program from Window Schedule? Am i right?
    For my view is "Yes".

    1. Write Simple prorgam (c#)
    2. Window Schedule Call to ur prog.
    3. Public CU (in NAV)
    4. CU call to your import rpt. (in NAV).

    I hope someone can give to you best ans. That is from my point :)

    Regards,
    Yukon

    ok then... now i get it...
    but i just dont know how to code open the company
  • julkifli33julkifli33 Member Posts: 1,091
    do any of you have simple code
    how web service execute codeunit?
    for example i have code in my code unit like this :
    OnRun()
    MESSAGE('Hello World');
    

    is it can be showed in webservices?
    or we should create function?
  • julkifli33julkifli33 Member Posts: 1,091

    <?xml version="1.0"?>
    -<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">-<s:Body>-<s:Fault&gt;
    <faultcode xmlns:a="urn:microsoft-dynamics-schemas/error">a:Microsoft.Dynamics.Nav.Service.WebServices.ServiceBrokerException</faultcode>
    <faultstring xml:lang="en-US">Service "Company name/Services/Codeunit/TWC_Import" was not found!</faultstring>-
    <detail><string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"&gt;Service "Company Name/Services/Codeunit/TWC_Import" was not found!</string></detail></s:Fault></s:Body></s:Envelope>

    why my services not found?
    i already published the codeunit
    and i already start the service for webservice
    what did i miss?
  • julkifli33julkifli33 Member Posts: 1,091
    hi ...
    i want to know
    i have created new codeunit --> 50001
    from this codeunit i trigger codeunit 80 (which is sales post)

    in order to use this in webservice, do i need to publish this codeunit 80 as well ?
    or just codeunit 50001?
    thanks
  • ClausHamannClausHamann Member Posts: 80
    You only need to publish C50001. You do not need to public C80 as long as you only call C80 though C50001.

    Regards
  • casio11casio11 Member Posts: 12
    Hi all,

    I created C# app which has two textboxes which i use as a parametars in function from Codeunit, but i dont have return parametars, my function only modify one fields in NAV.
    This is C# app:
    152hw7hofi77.png
    This is NAV:
    g31fr99a4mms.png
    This is error in Event Viewer:
    0vo5komy6lbx.png




Sign In or Register to comment.