"Unable to connect to the remote server" error

Jun 24, 2008 at 7:16 AM
Hi,

We are using Web Service Software Factory to create WCF service. In the service implemntation we are creating another web request to connect third party web service like this:

string url = "http://staging.whatsonwhen.com/sisp/trisept/index.htm?fx=xml.articlesearch&loc_id=133913";

 

 

WebRequest webRequest = WebRequest.Create(url);

 

webRequest.ContentType =

"text/xml";

 

webRequest.Proxy.Credentials =

CredentialCache.DefaultCredentials;

 

 

HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

 

 

Stream responseStream = webResponse.GetResponseStream();

 

 

StreamReader responseStreamReader = new StreamReader(responseStream);

 

 

string responseXml = responseStreamReader.ReadToEnd();

 

 

XmlDocument responseXmlDocument = new XmlDocument();

 

responseXmlDocument.LoadXml(responseXml);

But while executing the line, HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse() I am getting the error: "Unable to connect to the remote server" with the inner exception "No connection could be made because the target machine actively refused it 217.204.10.77:80".

But when I am trying to execute the same code from a simple windows application, I don't get this error.

 

 

 

 

 

 

Can somebody help me on this?

 

Developer
Jun 24, 2008 at 4:08 PM

Hi prasenjitg, connection problems can be caused by many factors. In this case, you can try using your own credentials instead of the default ones. To achieve this, you should modify your code where you set the webRequest.Proxy.Credentials property. Try setting this value with a new instance of System.Net.NetworkCredential (name, password).

Thanks



prasenjitg wrote:
Hi,

We are using Web Service Software Factory to create WCF service. In the service implemntation we are creating another web request to connect third party web service like this:

string url = "http://staging.whatsonwhen.com/sisp/trisept/index.htm?fx=xml.articlesearch&loc_id=133913";

 

 

 

WebRequest webRequest = WebRequest.Create(url);

 

webRequest.ContentType =

 

"text/xml";

 

webRequest.Proxy.Credentials =

 

CredentialCache.DefaultCredentials;

 

 

 

HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

 

 

 

Stream responseStream = webResponse.GetResponseStream();

 

 

 

StreamReader responseStreamReader = new StreamReader(responseStream);

 

 

 

string responseXml = responseStreamReader.ReadToEnd();

 

 

 

XmlDocument responseXmlDocument = new XmlDocument();

 

responseXmlDocument.LoadXml(responseXml);

But while executing the line, HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse() I am getting the error: "Unable to connect to the remote server" with the inner exception "No connection could be made because the target machine actively refused it 217.204.10.77:80".

But when I am trying to execute the same code from a simple windows application, I don't get this error.

 

 

 

 

 

 

 

 

Can somebody help me on this?

 

 




Jun 25, 2008 at 9:04 AM
Hi,

I have tried using my own credentials as per your suggestion. But it doesn't seem working.