我正在使用谷歌的GeoCode API返回用户在搜索框中输入的地址的lat/long值。我的代码似乎是正确的,但我遇到了一个安全异常问题。当我使用Fiddler检查呼叫时,我可以看到呼叫正在发送,但是clientaccesspolicy.xml有一个问题。
似乎我的WPF应用程序要求Google有一个clientaccesspolicy.xml,但是Google没有。因此,我可能需要代理来调用Google的API。有什么想法或工作吗?
代码
private void RequestResponseHandler(IAsyncResult asyncResult)
{
HttpWebResponse response = null;
Stream responseStream = null;
try
{
response = (HttpWebResponse)request.EndGetResponse(asyncResult);
responseStream = response.GetResponseStream();
var xdoc = XDocument.Load(responseStream);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}费德勒


发布于 2017-01-07 01:57:06
据我所知,您在Silverlight应用程序中使用了这段代码,该应用程序对跨域请求相当挑剔。在执行任何请求之前,Silverlight运行时尝试在目标服务器上找到clientaccesspolicy.xml (在您的例子中是maps.googleapis.com),如果它失败,它将尝试查找crossdomain.xml。显然,服务器没有这样的文件,因此运行时抛出SecurityException。
作为解决办法,您可以将请求代理到Google:
https://stackoverflow.com/questions/41516750
复制相似问题