连接到Google的距离矩阵服务时“无法连接到远程服务器”

时间:2012-04-13 14:33:23

标签: c# web-services

我遇到了这个问题......我有一个使用框架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

如果我尝试直接从Web服务器调用来自浏览器的Web服务.... http://maps.googleapis.com/maps/api/distancematrix/xml?&origins=milano&destinations=roma&units=metric&sensor=false&language=it

..一切正常,我可以看到XML文档

0 个答案:

没有答案