Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,
i have a web api library that consume external web services, after the development using Visual studio, i run it then try to consume the web api function, it works fine.
after i deployed under the IIS an error occurred:
"Message": "An error has occurred.",
"ExceptionMessage": "Unable to connect to the remote server",
"ExceptionType": "System.Net.WebException",
"StackTrace": "  
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) 
at System.Net.HttpWebRequest.GetRequestStream()


What I have tried:

i try to debug to catch the error on code level:
C#
WebRequest webRequest = WebRequest.Create("http://XXXXXXXXXXXXXXXXXXXX/webservice/certificate.php");
HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml";
httpRequest.Headers.Add("SOAPAction: http://xxxxxxxxxxxxxxxxxxxxxx/webservice/certificate.php/" + methodName);

            Stream requestStream = httpRequest.GetRequestStream();
            //Create Stream and Complete Request
            StreamWriter streamWriter = new StreamWriter(requestStream);
            string mergedformat = string.Format(GetSoapString(), requestXmlString);
            streamWriter.Write(string.Format(GetSoapString(), requestXmlString));
            streamWriter.Close();
Posted
Updated 17-May-19 2:54am
v2

1 solution

There Might be some firewall enabled on your network policy which is stopping this request.
try below solution in your config file

<system.net>
<defaultproxy>
<proxy usesystemdefault="False"
="" proxyaddress="Specify Your Proxy Address: Specify Port Number"
bypassonlocal="False">

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900