1

In the beginning, I was trying to find any solution for my issue but I didn't find anything.

I am Dynamics NAV Developer so C# is not my "native" language ;)

I have to connect my Win Form Application with Microsoft Dynamics NAV so I want to use Web Reference (SOAP).

This application is created for Smart devices (Windows Mobile 5.0) in Visual Studio 2008.

I added the Web Reference by right-clicking on my solution and selecting "Add Web Reference". My reference is named as "WS", so In my code (button click function) I try to use this reference i.e. entering WS.Collectors webservice = WS.Collectors();

When I try to compile my project, I have the following error:

Error 1 The type or namespace name 'WS' could not be found (are you missing a using directive or an assembly reference?) (...)

I also tried to enter using WS.Collectors but it's not working.

How can I use my Web Reference in my C# Code and add some data to it?

Screenshot

Thanks in advance!

AnonyM
  • 11
  • 3
  • I edited this post ;), it was just mistake in this text. Obviously I used "WS". Any ideas? ;) – AnonyM Aug 16 '18 at 22:05
  • Do you have a 'using WS;` directive with your other using directives? – Tim Aug 16 '18 at 22:16
  • I added a screenshot to my post. You can check it. I see a blue line under 'WS' Code ;) – AnonyM Aug 16 '18 at 22:17
  • Do you see the web reference in the right-hand Solution Explorer window underneath the project to which you added it? If so, can you expand it? You should see a web service class in there (ignore all the other classes). What namespace is that class in? – Always Learning Aug 16 '18 at 23:15
  • 1
    Also, have you tried `using WS;` Just put that at top. – Always Learning Aug 16 '18 at 23:19
  • 1. I can expand it. I have 1 "wsdl" file and 1 "map" file. I don't see any classes for this web reference. 2. I tried to put "using WS" and MyNamespace.WS and I have the same error. – AnonyM Aug 17 '18 at 07:04
  • I'm not very familiar with the latest NAV stuff but it looks like WS is not the namespace used. Maybe it is something else like "NavSOAPService" or even "Microsoft.Dynamics.WS"? One possible way to find out is look at the reference in the Object Browser in visual studio. – Jeff R. Aug 17 '18 at 15:30
  • @JeffR.Thanks for your message. The biggest problem is, that I don't see my web reference in Object Browser. I don't know, where is the problem and how to resolve it. – AnonyM Aug 18 '18 at 08:04
  • I'm not sure if this applies to your project but did you add the web reference following the procedure described here: https://learn.microsoft.com/en-us/dynamics-nav/walkthrough--registering-and-using-a-page-web-service--soap-#calling-the-web-service. particularly step 6 & 7 where it says to rename localhost to WebService and use that as the namespace? – Jeff R. Aug 23 '18 at 17:13

1 Answers1

0

You need to add appconfig file where you specify your app setting

<?xml version="1.0" encoding="utf-8" ?>
 <configuration>
 <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
 </startup>
 <appSettings>
 <add key="ServiceBaseUrl" value="http://yourserver" />
 <add key="ServicePort" value="yourportvalue"/>
 <add key="InstanceName" value="DynamicsNAV"/>
 <add key="ServiceType" value="Codeunit"/>
 <add key="ServiceName" value="Your Service Name" />
 <add key="CompanyName" value="your company name"/>
 <add key="ServiceBaseOther"  value="WS"/>
 <add key="UserName"  value="YourUsername"/>
 <add key="Password"  value="YourPassword"/>
 <add key="Domain"  value="Your Domain"/>
 <add key="TimeInterval"  value="60000"/>
 </appSettings>
</configuration> 
Mubasher
  • 1
  • 2