CrossDominaPolicy错误:尝试访问WCF服务时。 [英] CrossDominaPolicy Error : when trying to access a WCF Service.

查看:60
本文介绍了CrossDominaPolicy错误:尝试访问WCF服务时。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

目前我们在登录页面中为Sharepoint 2013使用自托管WCF,我们在根目录中添加了ClientAccessPolicy.xml和CrossDomainPolicy.xml服务器和客户端计算机,为了安全起见,我们还在WCF服务中包含了ClientAcessPolicy.xml
和CrossDomainPolicy.xml,并且在Internet Explorer中调用WCF服务时,一切正常,我们可以访问ClientAcessPolicy和CrossdoaminPolicy也是服务的内部功能,来自同一局域网上的本地托管的
服务器,当我们检查Fiddler时,我们可以看到来自InternetExplorer的呼叫
http:// localhost :XXXXX / ClientAccessPolicy.xml 被提取。

Presently we are using a self-hosted WCF for Sharepoint 2013 in Login Page, we have added the ClientAccessPolicy.xml and CrossDomainPolicy.xml in Root directory of the Server and the Client machine and for safe side we has also included the ClientAcessPolicy.xml and CrossDomainPolicy.xml in the WCF service and when the WCF service is called in Internet Explore everything is working fine and we could access the ClientAcessPolicy and CrossdoaminPolicy also the internal function of the Service, from a locally hosted server which is on the same LAN, when we check in Fiddler we can see the call from InternetExplorer http://localhost:XXXXX/ClientAccessPolicy.xml being fetched.

问题是当我们尝试访问已部署的SP2013的同一个SliverLight按钮或启用了SliverLight的登录页面时在Microsoft Azure VM上,我们无法访问该服务,并且我们收到了下面提到的
错误。

The problem is when we are trying to access the same SliverLight button or SliverLight enabled Login Page of SP2013 which is deployed on Microsoft Azure VM we are not able to access the service and we are getting the below mentioned error.

System.ServiceModel.CommunicationException:[CrossDomainError]:http :// localhost:XXXXX / XXXXXX资源字符串不可用。通常,密钥和参数提供了足够的信息来诊断问题。请参阅http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50901.00&File=System.ServiceModel.dll&Key=CrossDomainError
---> System.Security.SecurityException ---> System.Security.SecurityException:[Arg_SecurityException]:资源字符串不可用。通常,密钥和参数提供了足够的信息来诊断问题。请参阅http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50901.00&File=mscorlib.dll&Key=Arg_SecurityException


  ;在System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

 在System.Net.Browser.BrowserHttpWebRequest。<> c__DisplayClassa。< EndGetResponse> b__9(Object sendState)

 在System.Net.Browser.AsyncHelper。<> c__DisplayClass4。< BeginOnUI> b__0(对象sendState)

  ---内部异常堆栈跟踪结束---

 在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state)

 在System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

  at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

  ---内部异常堆栈跟踪结束---

 在System.ServiceModel.AsyncResult.End [TAsyncResult](IAsyncResult结果)

  at System.ServiceModel.Channels.ServiceChannel.EndCall(String action,Object [] outs,IAsyncResult results)

 在System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName,Object [] args,IAsyncResult result)

 在SLLogin.iCubeWCFsvc.Service1Client.Service1ClientChannel.EndGenKey(IAsyncResult结果)

 在SLLogin.iCubeWCFsvc.Service1Client.SLLogin.iCubeWCFsvc.IService1.EndGenKey(IAsyncResult结果)

 在SLLogin.iCubeWCFsvc.Service1Client.OnEndGenKey(IAsyncResult结果)

 在System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)" TextWrapping = QUOT;包覆与QUOT;宽度= QUOT; 1000"的xmlns:X =" HTTP://schemas.microsoft.com/winfx/2006/xaml" />

System.ServiceModel.CommunicationException: [CrossDomainError]: http://localhost:XXXXX/XXXXXX resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50901.00&File=System.ServiceModel.dll&Key=CrossDomainError ---> System.Security.SecurityException ---> System.Security.SecurityException: [Arg_SecurityException]: resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=5.1.50901.00&File=mscorlib.dll&Key=Arg_SecurityException
  at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
  at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
  at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>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.AsyncResult.End[TAsyncResult](IAsyncResult result)
  at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
  at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
  at SLLogin.iCubeWCFsvc.Service1Client.Service1ClientChannel.EndGenKey(IAsyncResult result)
  at SLLogin.iCubeWCFsvc.Service1Client.SLLogin.iCubeWCFsvc.IService1.EndGenKey(IAsyncResult result)
  at SLLogin.iCubeWCFsvc.Service1Client.OnEndGenKey(IAsyncResult result)
  at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)" TextWrapping="Wrap" Width="1000" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />

我们还尝试在 Fiddler 中查看正在调用WCF服务的天气但是我们看不到任何一个调用ClientAccessPolicy或客户端计算机中安装的WCF服务中的功能,我们还尝试了一个工具
SliverlightSpy ,但我们找不到正确的错误或原因。 

We have also tried in Fiddler to check weather the WCF service is being called but we could not see any call of the either the ClientAccessPolicy or the functions in the WCF service installed in the Client Machine, we also tried a tool SliverlightSpy but we could not find correct error or the reason. 

 先谢谢

任何建议都会非常有用,

Any suggestion will be very helpful,

谢谢和问候

Harsha

推荐答案


最后几周的斗争了解了拥有ClientAcessPolicy.xml和CrossDomainPolicy.xml在根目录中不会提供ur请求,ClientAcessPolicy.xml和C. rossDomianPolicy.xml必须仅通过该服务发送。

Finally weeks of struggle  got to know that having ClientAcessPolicy.xml and CrossDomainPolicy.xml in the root directory will not serve u r request, the ClientAcessPolicy.xml and CrossDomianPolicy.xml must be sent through the service only.


按照以下步骤解决此问题

Follow the below steps to solve this issue



  1. 在Iservice1.cs中添加一个新的NameSpace,如下所示

  1. Add a new NameSpace in Iservice1.cs as shown below

[ServiceContract(Namespace = "http://ServiceWCF")]

public interface IPolicyRetriever
 {
   [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]

   Stream GetSilverlightPolicy();

   [OperationContract, WebGet(UriTemplate = "/crossdomain.xml")]

   Stream GetFlashPolicy();
 };



  • 现在编辑带有编辑的Service1.svc文件,

  • Now edit the Service1.svc file with edits,

    public class PolicyClass : IPolicyRetriever
    {
        Stream StringToStream(string result)
        {
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";
            return new MemoryStream(Encoding.UTF8.GetBytes(result));
        }
        public Stream GetSilverlightPolicy()
        {
            string result = @"<?xml version=""1.0"" encoding=""utf-8""?>
                            <access-policy>
                                <cross-domain-access>
                                    <policy>
                                        <allow-from http-request-headers=""*"">
                                            <domain uri=""*""/>
                                        </allow-from>
                                        <grant-to>
                                            <resource path=""/"" include-subpaths=""true""/>
                                        </grant-to>
                                    </policy>
                                </cross-domain-access>
                            </access-policy>";
            return StringToStream(result);
        }
        public Stream GetFlashPolicy()
        {
            string result = @"<?xml version=""1.0""?>
                            <!DOCTYPE cross-domain-policySYSTEM""http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"">
                            <cross-domain-policy>
                                <allow-access-from domain=""*"" />
                            </cross-domain-policy>";
            return StringToStream(result);
        }
    }



  • 现在在项目位置添加文件

  • Now Add both the file in the Project Location

    服务启动并立即运行在浏览器中测试是否可以从Internet Explorer访问ClientAccesspolicy.xml和Crossdoaminpolicy.xml。完成所有这些后,必须在浏览器
    中将Microsoft Azure VM链接添加为可信站点或域

    After the service is up and running now test in the browser whether the ClientAccesspolicy.xml and Crossdoaminpolicy.xml is accessible from Internet explorer. After all this is done the Microsoft Azure VM link must be added as a trusted site or domain in the browser

    1.首先导航到Internet Explorer-> Internet选项 - >安全性 - >本地Intranet->网站

    1. First navigate to Internet Explorer-> Internet Options ->Security ->Local Intranet-> Sites

    现在选中自动检测复选框Intranet网络点击Advanced并添加VM的相应站点URL

    Now check the Check box for Automatically detect intranet network click on Advanced and add the respective Site URL of the VM

    2.  Internet Explorer-> Internet Options - > Security - > Trusted Site,添加SP2013 URL作为添加的URL

    2. Internet Explorer-> Internet Options ->Security ->Trusted Site, add the SP2013 URL which as an added URL

    现在在同一窗口中单击自定义级别 启用所有.Net Framework,Active X控件,启用.Net Framework设置

    Now in the same window click on the Custom Level  Enable all .Net Framework, Active X Controls, Enable .Net Framework Setup

    3.现在转到高级选项卡并取消选中Disable th e脚本调试(Internet Explorer), 禁用脚本调试(其他)

    3. Now move to the advanced Tab and uncheck the Disable the Script Debugging(Internet Explorer), Disable the Script Debugging(others)

    在同一个选项卡中,我们还需要启用一些选项,它们是允许从CD到的活动内容在我的计算机上运行,​​允许Active Controls在我的计算机上的文件中运行,启用本机XMLHTTP支持。

    In the same Tab we also need to enable some of the options and they are Allow Active Contents from CD's to run on my computer, Allow Active Controls to run in files on my Computer, Enable Native XMLHTTP Support.

    完成所有这些后查看天气Sliverlight应用程序正常运行。确保如果这些步骤处理正确,应用程序将完美运行。

    After all these are done check weather the Sliverlight application is running properly. For sure if these steps are handles correctly the application will run perfectly.


    这篇关于CrossDominaPolicy错误:尝试访问WCF服务时。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆