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.
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.
[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.
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.):
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 ---
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.
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.
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'.SoapSerializer30
Comments
Did you try this ?
http://www.mibuso.com/dlinfo.asp?FileID=539
RIS Plus, LLC
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.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
See this article http://msdn.microsoft.com/en-us/library/aa973247.aspx
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-
WebService Code -
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?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Do we have any other example codes apart from the one mentioned above?
The difference in my code from is in variable type -
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 ...
How did you sort out the problem of the blank parameter?
I'm having the same issue...
Thanks a lot
<?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??
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.
Try changing it with this one
Here txtInputParam is the parameter absorbed by my WebService and a text variable "paramNAVCapInput" is being used to supply the value
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?
thanks.
hong
http://blogs.msdn.com/freddyk/archive/2010/01/22/connecting-to-nav-web-services-from-microsoft-dynamics-nav-2009-sp1.aspx
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.
locautSoapSerializer = 'Microsoft Soap Type Library v3.0'.SoapSerializer30