Simple Page getting error through web services

jwilderjwilder Member Posts: 263
edited 2013-03-03 in NAV Three Tier
I have numerous codeunit web services that are running and working. I am trying to get the easiest of page web services working and I get the following error in Visual Studio: "ReplaceWithAPercentEncodedCompanyName/Page/Customer" was not found!

I have exposed the Customer Page in NAV

I started a C# project with the following code:
WS.Customer_Service service = new WS.Customer_Service();
service.UseDefaultCredentials = true;
WS.Customer cust = service.Read("100000");

WS is the reference to the web service. Trying to keep this as simple as possible. The error happens on the last line which is where the call to NAV is actually made. Same page runs through RTC no problem. The service tier customsetting.config is normal except we have key="WebServicesUseNTLMAuthentication" value="true">.

Any thoughts?

Answers

  • ara3nara3n Member Posts: 9,256
    Does your company have any apostrophe ?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • jwilderjwilder Member Posts: 263
    It does not have an apostrophe. There is a space though. Come to think of it how does it know what company to use (we have 3 in this database)? When consuming a page web service you do not use the service.url method right (only for codeunits)? When I set up the web reference I used this:
    http://servername:7047/DynamicsNAV/WS/Page/Customer. I have not chose a company anywhere so it must have something to do with this.
  • jwilderjwilder Member Posts: 263
    I tripped across something and have solved this but I am still a little confused. I retested a simple codeunit web service and got the same error. Turns out I left out the service.url line of code. I added this in and my codeunit worked.

    Know back to my original problem whihc was consuming a page. It seems the page was showing a similar problem. So I added this line of c# code:
    service.Url = "http://mycomputer:7047/DynamicsNAV/WS/mycompany/Page/Customer";

    and it now works. The weird thing is that I have not seen that this is required to call service.url when consuming a page. Freddy's blog, Waldo's blog, NAV help do not do this. You definately need to do this for Codeunit web services but why does no one else require this when consuming a page? Even though I have a solution I think there is still something not right. ANy thoughts would be appreciated.
  • jwilderjwilder Member Posts: 263
    I have my answer. It has to do with the url of the web reference. One way or the other you need to reference the company (obviously). So you either have to do it in the initial web reference by doing this:
    http://myserver:7047/DynamicsNAV/WS/mycompany/Page/Customer

    or you need to do it with the service.url method like this:
    service.url = "http://myserver:7047/DynamicsNAV/WS/mycompany/Page/Customer"

    In my case i used this url for the web reference:
    http://myserver:7047/DynamicsNAV/WS/Services
    and clicked through to the actual page service. By doing this it never knows what company you are talking about so it makes sense that I would be required to add this code:
    service.url = "http://myserver:7047/DynamicsNAV/WS/mycompany/Page/Customer";

    Otherwise it would not know what company to use. In a way this second method is nice because it lets you choose the company in your code not the actual web reference.
Sign In or Register to comment.