A call to System.Net.HttpWebRequest.GetResponse failed with this message: Object reference not set to an instance of an object.
lgRequest := lgRequest.HttpWebRequest; lgRequest.Create('http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=CAD'); lgResponse := lgResponse.HttpWebResponse; lgResponse := lgRequest.GetResponse();
lgRequest DotNet System.Net.HttpWebRequest.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' lgResponse DotNet System.Net.HttpWebResponse.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Comments
Try this
Thanks a lot. This solution help me for this task.
But, if it's posible, I would like to know what a mistake I made in my code?
If I am not mistaken, you should call method "send" first before expecting a web response.
From the code you are writing is just create an instance dot net object and it certainly does not perform web request immediately.
Another point you should check if response is ready. Internet response should not be faster than local CPU to execute the command instruction. So there are few things you can improve first! Good luck!
You need to change this line
for this one
How I can automatically handle this error? Because XMLDoc.Load didn't return any results of his work.
I am getting following error in your last piece of code:
A call to System.Xml.XmlDocument.InnerXml failed with this message: '>' is an unexpected token. The expected token is '"' or '''. Line 1, position 62.
Does this mean the desired request format at the server has changed?
In addition to above I am getting some other errors in similar code for consuming NAV webservice which is called from another NAV database:
1. 500 Internal Error
2. This message is for C/AL programmers: A call to System.Net.HttpWebRequest.GetResponse failed with this message: The remote server returned an error: (411) Length Required.
3. A call to MSXML.XMLHTTPRequestClass.send failed with this message.Value does not fall within the expected range
Another issue is you are using
MSXML.XMLHTTPRequestClass.'Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
which is not available in one of my server and could not find its installed setup also. Is there any good replacement of above DotNet component? Is there any sample code for Adding SOAPEnvelope and consuming NAV webservice using DotNet components (not automation variables) for NAV2013 & NAV 2015?
Thanks in advance.
Linkedin Profile: http://in.linkedin.com/in/dhanrajbansal
im trying to use the SOAP GetRate Function in NAV2015 an getting the following Message:
System.Xml.XmlDocument.InnerXml : Root element is missing.
The Debugger stops here:
XMLDoc.InnerXml := HttpRequest.responseText;
EDIT:
I was a bit to fast.
issue was solved quite easy: I repaced the < and > characters with <> and it works.
Thanks!
Here the complete Code: