Call Web Service from NAV
Soumyadip
Member Posts: 209
Hi,
I know how to create page/codeunit web services and to expose them. I can call NAV web services from external (C#) programs.
How do i call an external Web Service from NAV?
Regards,
Soumyadip
I know how to create page/codeunit web services and to expose them. I can call NAV web services from external (C#) programs.
How do i call an external Web Service from NAV?
Regards,
Soumyadip
0
Comments
-
0
-
Is there any documentation available on it?0
-
-
Thanks.
I have gone through these document. With help of this i can expose a Page or Codeunit web service from NAV. I can consume the same from a C# program.
But, I want to consume a web service from NAV exposed by 3rd Party application. (e.g In customer card, i want to show the current stock (NASDAQ) value of the customer. To do that i need to call any standard web services exposed by different websites. How do i call a web service FROM NAV?)
I have got some sample code from the download section but was looking for some documentation as we do have some (to call NAV web services from outside) in MSDN/Product DVD.0 -
Can anyone help me here?0
-
I recommend to read SOAP SDK documentation. There is no specific DOC for consuming WS within NAV... (or may be it is but it is not known)0
-
The way I've gone about this is to create a COM object with C# which interfaces with the service in question. Since the C# is a COM object (.dll) you can define a public interface with properties and functions which can be called from within NAV as an automation object.
See this article http://msdn.microsoft.com/en-us/library/aa973247.aspx0 -
I was trying this link - http://www.mibuso.com/dlinfo.asp?FileID=539
I can call the Web Service now. It is generating the XML file in specified path. \:D/
Still, bit of problem remains...
When I am passing parameters to WebService, it is not recognizing it. and within the WebService(function) treating the input parameter as blank.
Pasting two blocks of code -
NAV CODE-CREATE(locautSoapHttpConnector); locautSoapHttpConnector.Property('EndPointURL', 'http://localhost:1041/Service1.asmx'); locautSoapHttpConnector.Connect; locautSoapHttpConnector.Property('AuthUser', 'User'); locautSoapHttpConnector.Property('AuthPassword', 'Password'); locautSoapHttpConnector.Property('Timeout', 5 * 1000); locautSoapHttpConnector.Property('SoapAction','http://temp.com/Math_Cos'); locautSoapHttpConnector.BeginMessage; CREATE(locautSoapSerializer); locautSoapSerializer.Init(locautSoapHttpConnector.InputStream); locautSoapSerializer.StartEnvelope('SOAP','STANDARD'); locautSoapSerializer.StartBody; locautSoapSerializer.StartElement('Math_Cos'); locautSoapSerializer.StartElement('Angle'); locautSoapSerializer.WriteString('45'); locautSoapSerializer.EndElement; locautSoapSerializer.EndElement; locautSoapSerializer.EndBody; locautSoapSerializer.EndEnvelope; locautSoapHttpConnector.EndMessage; CREATE(locautXmlDoc); locautXmlDoc.load(locautSoapHttpConnector.OutputStream); locautXmlDoc.save('C:\Soumya\DealerMngt\Test4Dealer\MathCos.xml');
WebService Code -[System.Web.Services.WebMethod(Description = "Test4Dealer Math Cos")] public double Math_Cos(double Angle) { return System.Math.Cos(Angle); }
The result i am getting is 1. That is value of Cos 0. I have tried the same with some other functions with different parameter types. But the result proves that the input parameter has been ignored.
Just to add, all the functions are runing fine when i am running .asmx file in browser.
Any idea, what am i missing here?0 -
I am using same and it is working, there is only difference in some parameters when initializing the call (variables are named as I use them, but they are same as yours by type etc.):
lauSoapSerializer.Init(lauSoapConnector.InputStream); lauSoapSerializer.StartEnvelope(); lauSoapSerializer.StartBody('STANDARD'); lauSoapSerializer.StartElement('Math_Cos','http://temp.com');0 -
No luck with this one as well -
CREATE(locautSoapSerializer); locautSoapSerializer.Init(locautSoapHttpConnector.InputStream); locautSoapSerializer.StartEnvelope(); locautSoapSerializer.StartBody('STANDARD'); locautSoapSerializer.StartElement('Math_Cos','http://temp.com'); locautSoapSerializer.StartElement('Angle'); locautSoapSerializer.WriteString('23'); locautSoapSerializer.EndElement; locautSoapSerializer.EndElement;0 -
Can anyone tell me why with the above mentioned block of code, i am being able to call a webservice but it is taking the parameter as 0 or blank?
Do we have any other example codes apart from the one mentioned above?0 -
I was trying this link - http://www.mibuso.com/dlinfo.asp?FileID=539
I can call the Web Service now. It is generating the XML file in specified path.
Still, bit of problem remains...
When I am passing parameters to WebService, it is not recognizing it. and within the WebService(function) treating the input parameter as blank.
The difference in my code from
is in variable type -I was trying this link - http://www.mibuso.com/dlinfo.asp?FileID=539
i am using -
locautSoapHttpConnector = 'Microsoft Soap Type Library v3.0'.HttpConnector30
locautSoapSerializer = 'Microsoft Soap Type Library v3.0'.SoapSerializer30
Hope this is not causing the problem ...
0 -
It is working now \:D/0
-
Soumyadip wrote:It is working now \:D/
How did you sort out the problem of the blank parameter?
I'm having the same issue...
Thanks a lot0 -
I have called the web service method with parameters and also saved the OutputStream in an XML file. This is the content of the file:
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---> Object reference not set to an instance of an object.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
This is the code used from NAV:
CREATE(locautSoapHttpConnector);
locautSoapHttpConnector.Property('EndPointURL','http://10.16.16.94/DemoService/Service.asmx');
locautSoapHttpConnector.Connect;
locautSoapHttpConnector.Property('AuthUser','User');
locautSoapHttpConnector.Property('AuthPassword','Password');
locautSoapHttpConnector.Property('Timeout', 5 * 1000);
locautSoapHttpConnector.Property('SoapAction','http://tempuri.org/ToUpper');
locautSoapHttpConnector.BeginMessage;
CREATE(locautSoapSerializer);
locautSoapSerializer.Init(locautSoapHttpConnector.InputStream);
locautSoapSerializer.startEnvelope();
locautSoapSerializer.startBody('STANDARD');
locautSoapSerializer.startElement('ToUpper','http://tempuri.org');
locautSoapSerializer.startElement('input');
locautSoapSerializer.writeString('navision');
locautSoapSerializer.endElement;
locautSoapSerializer.endElement;
locautSoapSerializer.endBody;
locautSoapSerializer.endEnvelope;
locautSoapHttpConnector.EndMessage;
CREATE(locautXmlDoc);
locautXmlDoc.load(locautSoapHttpConnector.OutputStream);
locautXmlDoc.save('c:\temp2.xml');
Can anybode suggest why this fault code is coming??0 -
Hi,
I have hosted the web service in my local machine and now the OutputStream is showing a different fault code:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Service.ToUpper(String input) --- End of inner exception stack trace ---
Could anyone suggest how to resolve this?
Thanks a lot.0 -
I think the problem is with you SoapSerializer. More specificaly in this block of the code
locautSoapSerializer.startElement('input'); locautSoapSerializer.writeString('navision'); locautSoapSerializer.endElement
Try changing it with this onelocautSoapSerializer.WriteXml('<ToUpper xmlns="http://tempuri.org/"><txtInputParam>' + paramNAVCapInput + '</txtInputParam></ToUpper>');Here txtInputParam is the parameter absorbed by my WebService and a text variable "paramNAVCapInput" is being used to supply the value0 -
It is working fine this way.. Thanks. 0 -
Great...
I was wondering why the more conventional way of building the SOAP message (with StartElement and WriteString) is not working in our case...
Any idea?0 -
I have difficulty to install soap component into NAV or computer. I download ms soap tool kit and install on my computer, I cannot find those component in NAV or even on in DCOM component. I did even try to register those component in nav. Please help.
thanks.
hong0 -
Maybe you can use this
http://blogs.msdn.com/freddyk/archive/2010/01/22/connecting-to-nav-web-services-from-microsoft-dynamics-nav-2009-sp1.aspxFreddy Kristiansen
Group Program Manager, Client
Microsoft Dynamics NAV
http://blogs.msdn.com/freddyk
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.0 -
Where can I find equivalent code to wat has been mentioned for NAV 2016? I am unable to find the Subtypes for variables : locautSoapHttpConnector = 'Microsoft Soap Type Library v3.0'.HttpConnector30 &
locautSoapSerializer = 'Microsoft Soap Type Library v3.0'.SoapSerializer300
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 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

