我遇到了这个问题......我有一个使用框架 4.0 开发的 Web 应用程序,它调用一个谷歌网络服务(距离矩阵)......像这样
XPathDocument Doc = new XPathDocument(
"http://maps.googleapis.com/maps/api/distancematrix/xml?&origins=" + start +
"&destinations=" + stop + "&units=metric&sensor=false&language=it");
在我的客户端上一切正常..在使用 IIS 在 Web 服务器上部署应用程序后,所有问题都开始了......我有这个错误
Unable to connect to the remote server
[SocketException (0x274d): Unable to connect to the remote server 173.194.65.95:80]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +305
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +699
[WebException: Impossibile effettuare la connessione al server remoto.]
System.Net.HttpWebRequest.GetResponse() +7769892
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy) +160
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +318
System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +75
System.Threading.CompressedStack.runTryCode(Object userData) +136
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +118
System.Xml.XmlTextReaderImpl.OpenUrl() +4996487
System.Xml.XmlTextReaderImpl.Read() +120
System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space) +386
System.Xml.XPath.XPathDocument..ctor(String uri, XmlSpace space) +130
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691
如果我尝试直接从网络服务器调用来自浏览器的网络服务.... http://maps.googleapis.com/maps/api/distancematrix/xml?&origins=milano&destinations=roma&units=metric&sensor=false&language=it
..一切正常,我可以看到 XML 文档