I am using the sample code to dynamically invoke a web service from this site:
http://www.crowsprogramming.com/archives/66
The issue that I am facing is when I use the Class to call a web service from a web application I get the following error: “The remote host cannot be found” and the error happens at the following line of code:
if (!ServiceDescription.CanRead(xmlreader))
But if I use the same code from a windows application to connect to the web service:
http://www.w3schools.com/webservices/tempconvert.asmx?WSDL
it works fine. I am not sure how to resolve this issue. Has anyone else faced the same issue and was able to resolve it then would appreciate some pointers in the right direction.
The issue for me was the Proxy to be used to connect to the internet. The code needs to change at the following two places for the successful operation:
1] The method BuildServiceDescriptionImporter(XmlTextReader xmlreader) was changed to
2] The second piece of code that was to be changed was within the
public T InvokeMethod<T>( string serviceName, string methodName, params object[] args )methodadd the following code snippet before Invoking the method:
After doing those changes I was able to use the code to connect to a remote web service dynamically.
Hope this helps others facing the same issue as I did.