Connection NAV 2017 Web Service (Codeunit) with Universal Windows App

michael@platl.at
Member Posts: 2
Hi,
I hope someone can help me out. I'm just interested in trying out the new Windows Template Studio from VS2017. (btw. it's great)
I Created an app with Navigation Pane and MVVM Light + Grid. Nothing special so far.
In NAV I have a Codeunit Web Service with two parameters. (Request, Response) where Response is by Reference (VAR). I just write Response:= "Hello World" in the Function.
I'm strictly not able to get any result back with my app. I don't post any code here because my code is rubbish. I tried many ways.
In a simple Windows Forms application, I can connect through System.Web.Service
Like this ... Where ProcessRequest is my Function in the Codeunit and Webserv is the Published Service name
worked like charm
. But now I do not have a clue how I could connect to NAV and get my simple response back.
If anyone has some time left and knowledge in this I would love to get an answer how I can achieve this.
It's nothing I'm working on for a customer so there is no need to hurry for me. It's just a "would love to know" thing.
greetings
I hope someone can help me out. I'm just interested in trying out the new Windows Template Studio from VS2017. (btw. it's great)
I Created an app with Navigation Pane and MVVM Light + Grid. Nothing special so far.
In NAV I have a Codeunit Web Service with two parameters. (Request, Response) where Response is by Reference (VAR). I just write Response:= "Hello World" in the Function.
I'm strictly not able to get any result back with my app. I don't post any code here because my code is rubbish. I tried many ways.
In a simple Windows Forms application, I can connect through System.Web.Service
Like this ... Where ProcessRequest is my Function in the Codeunit and Webserv is the Published Service name
using System; using System.Net; using System.Web.Services; using System.Web.Services.Description; using System.Web.Services.Protocols; using System.Windows.Forms; namespace WebserviceTest { [System.ComponentModel.DesignerCategoryAttribute("code")] [WebServiceBinding(Name = "Webserv_Binding", Namespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv")] public class NAV2017ServiceClient : SoapHttpClientProtocol { public NAV2017ServiceClient(string url, string userName, string password, string domain, int timeout) { this.Url = url; this.Timeout = timeout * 1000; if (string.IsNullOrEmpty(userName)) this.UseDefaultCredentials = true; else this.Credentials = (ICredentials)new NetworkCredential(userName, password, domain); } [SoapDocumentMethod("urn:microsoft-dynamics-schemas/codeunit/Webserv:ProcessRequest", ParameterStyle = SoapParameterStyle.Wrapped, RequestNamespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv", ResponseElementName = "ProcessRequest_Result", ResponseNamespace = "urn:microsoft-dynamics-schemas/codeunit/Webserv", Use = SoapBindingUse.Literal)] public void ProcessRequest(string request, ref string response) { //MessageBox.Show(this.Url.ToString()); object[] objArray = this.Invoke("ProcessRequest", new object[2] { (object) request, (object) response }); response = (string)objArray[0]; } protected override WebRequest GetWebRequest(Uri uri) { WebRequest rq = base.GetWebRequest(uri); return rq; } } }
worked like charm

If anyone has some time left and knowledge in this I would love to get an answer how I can achieve this.
It's nothing I'm working on for a customer so there is no need to hurry for me. It's just a "would love to know" thing.
greetings
0
Answers
-
I would suggest you to add the web service in visual studio through the Add reference. If you add web service in visual studio like this, then you will be able to get your function directly in VS.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions