wcf - 调试 IIS Express Web 服务/silverlight 应用程序时出现安全错误

标签 wcf silverlight iis-express

我有一个 silverlight 应用程序托管在一个包含 WCF SOAP 网络服务的 asp.net 网络应用程序上。该应用程序在使用 SSL 的 HTTPS://... 链接下运行。当我将它部署到我们运行 IIS 7.5 的测试服务器上时,一切都按预期正常工作。 我还有第二个 Web 应用程序,包括一个 RESTful WCF 服务,它在我的本地计算机和提到的测试服务器上都使用 SSL 运行(但在这种情况下没有 silverlight 客户端)。

我的问题是 silverlight 客户端在应该进行反序列化的部分从 SOAP 服务获取响应时收到安全错误,但仅限于我的本地计算机。

    return base.Channel.EndGet...(IAsyncResult)  // <-- exception reported here:
    System.ServiceModel.CommunicationException: An error occurred while
    trying to make a request to URI 'https://localmachinename.domain.com:8000/Service.svc'.
    This could be due to attempting to access a service in a cross-domain way without a
    proper cross-domain policy in place, or a policy that is unsuitable for SOAP services.
    You may need to contact the owner of the service to publish a cross-domain policy file
    and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be
    caused by using internal types in the web service proxy without using the
    InternalsVisibleToAttribute attribute. Please see the inner exception for more
    details. ---> System.Security.SecurityException ---> 
    System.Security.SecurityException: Security error.    
    at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
    at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClassa.b__9(Object sendState)
    at System.Net.Browser.AsyncHelper.c__DisplayClass4.b__0(Object sendState)
    --- End of inner exception stack trace ---
    at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
    at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
    --- End of inner exception stack trace ---
    at System.ServiceModel.Channels.Remoting.RealProxy.Invoke(Object[] args)
    at proxy_2.EndGetTypes(IAsyncResult )
    at NameSpace.ClientClass.ServiceContractInterfaceImplementation.EndGetTypes(IAsyncResult result)

My clientaccesspolicy.xml for the SOAP service looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="*" />
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

有什么提示我做错了吗? 部署的应用程序在我们的测试网络服务器上运行良好。

2012 年 12 月 6 日:问题仍然存在。一些更新/更多信息:
Web 服务使用 Windows 身份验证和模拟。测试服务器和本地机器之间的唯一区别是应用程序池以不同的身份运行,在这两种情况下都是技术域用户。我发现的唯一区别是我本地机器上的用户在 Active Directory 中没有被授予“受信任的委派”标志。所以我认为这可能是 Kerberos 问题。但是,当我运行 Restful WCF 服务和客户端时,这从来都不是问题。此外,使用 SOAP 服务的 Windows 窗体客户端,一切都在我的本地机器上运行良好,并且开发/调试是可能的。
所以它必须是一个 Silverlight 问题。
我没有得到的是,假设这个可怕的安全错误是由跨域策略问题引起的,就像在大多数情况下一样,这些域在哪里交叉?一切都应该在本地机器上进行,没有调用其他服务。使用 IIS Express 不应该发生这种情况,对吗?
有人能帮忙吗?

最佳答案

clientaccesspolicy.xml 应该放在wwroot 文件夹中并且还包括crossdomain.xml

关于wcf - 调试 IIS Express Web 服务/silverlight 应用程序时出现安全错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13700442/

相关文章:

wcf - NHibernate和WCF : Performance (session reuse) vs.并发(同时请求)

c# - 删除序列化程序创建的空 xmlns

c# - WCF RESTFul 服务 - 404 端点未找到 2 个服务

silverlight - Silverlight 2 中的图像处理

vb.net - 从 Silverlight 4 调用 WCF 服务需要指导

asp.net - 将VS2012项目升级到VS2013网站,它不允许我指定IIS端口

asp.net-mvc-4 - 开发和测试网站和广告

c# - IIS 上的 WCF 服务。如何摆脱 URL 路径中的 "Service.svc"组件?

.net - 在 VS2010 中为 .NET 4 和 Silverlight 4 交叉编译而不复制文件

c# - 当启动应用程序是控制台应用程序时,防止 iisexpress 在解决方案中运行网站