NAV 2013 - Webservice call for Codeunit (without reference)
THUS
Member Posts: 5
Hi Guys,
I like to try a simple codeunit call and get the hardcoded string back. And i like to do that without adding web reference.
I tried this sample but without succes: http://stackoverflow.com/questions/1712 ... eb-service
Are there anyone who can make a simple sample if i want to get a response from a codeunit function?
Sample:
A codeunit with one parameter function.
HellowWorld(string name) -> EXIT('Hello ' + name)
And i like to get Hello John in a string in c#..
The sample i have is like this:
But i think it's wrong
i hope there are someone who can help me 
Have a nice day!
I like to try a simple codeunit call and get the hardcoded string back. And i like to do that without adding web reference.
I tried this sample but without succes: http://stackoverflow.com/questions/1712 ... eb-service
Are there anyone who can make a simple sample if i want to get a response from a codeunit function?
Sample:
A codeunit with one parameter function.
HellowWorld(string name) -> EXIT('Hello ' + name)
And i like to get Hello John in a string in c#..
The sample i have is like this:
string requestString = @"<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Test xmlns="urn:microsoft-dynamics-schemas/codeunit/test"></Test></soap:Body></soap:Envelope>";
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = null;
string url = "http://dev.vava.dk:7047/DynamicsNAV70/WS/CRONUS%20Danmark%20A%2FS/Codeunit/test";
byte[] requestBuffer = null;
System.IO.Stream postStream = null;
System.IO.Stream responseStream = null;
System.IO.StreamReader responseReader = null;
request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
request.ProtocolVersion = new Version(1, 1);
request.Method = "POST";
request.Headers.Add("SOAPAction", @"urn:microsoft-dynamics-schemas/codeunit/test:HelloWorld");
request.ContentType = @"application/xml; charset=utf-8";
requestBuffer = System.Text.Encoding.ASCII.GetBytes(requestString);
request.ContentLength = requestBuffer.Length;
request.Credentials = new System.Net.NetworkCredential("thusan", "Cey_121212");
postStream = request.GetRequestStream();
postStream.Write(requestBuffer, 0, requestBuffer.Length);
postStream.Close();
response = (System.Net.HttpWebResponse)request.GetResponse();
responseStream = response.GetResponseStream();
string response_result = string.Empty;
if (responseStream != null)
{
responseReader = new System.IO.StreamReader(responseStream);
response_result = responseReader.ReadToEnd();
}
Label1.Text = response_result;
But i think it's wrong
Have a nice day!
0
Comments
-
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
