通过Web API消费的在线Web服务 [英] Online web services consumed via web API
本文介绍了通过Web API消费的在线Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i有一个使用外部Web服务的web api库,在使用Visual Studio开发之后,我运行它然后尝试使用web api函数,它工作正常。
:
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()
我的尝试:
i尝试调试以捕获代码级别的错误:
What I have tried:
i try to debug to catch the error on code level:
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();
推荐答案
可能会在您的网络策略上启用一些防火墙来阻止此请求。
在配置文件中尝试以下解决方案
< system.net>
< defaultproxy>
< proxy usesystemdefault =False
=proxyaddress =指定您的代理地址:指定端口号
bypassonlocal =False >
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">
这篇关于通过Web API消费的在线Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文