Silverlight无法使用webservice Security Exception [英] Silverlight cannot use webservice Security Exception

查看:76
本文介绍了Silverlight无法使用webservice Security Exception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我以下问题,我正在尝试使用Web服务来显示位于我的网站上的数据库与Mocha的记录。在我的桌面上测试时应用程序运行正常,但在线测试时出现以下错误。您可以在此处测试 http://www.viewmypurchases.com/SalesRptTestPage.html 使用两个不同的地址,它们会产生不同的错误。


System.Reflection.TargetInvocationException:操作期间发生异常,导致结果无效。 检查InnerException是否有异常详细信息。 ---> System.ServiceModel.CommunicationException:尝试向URI"http://localhost/KIS_Mill_WebService.svc"发出请求时发生错误。这可能是由于尝试在没有适当的跨域策略的情况下以跨域方式访问服务,或者是不适合SOAP服务的策略。您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP标头。在不使用InternalsVisibleToAttribute属性的情况下,在Web服务代理中使用内部类型也可能导致此错误。有关更多详细信息,请参阅内部异常。 ---> System.Security.SecurityException ---> System.Security.SecurityException:安全错误。


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


在System.Net.Browser.BrowserHttpWebRequest。<> c__DisplayClass5。< EndGetResponse> b__4(Object sendState)


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


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


(SendOrPostCallback beginMethod,Object state)


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


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


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


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


at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)


在System.ServiceModel.Channels.ServiceChannel.EndCall(String action,Object [] out,IAsyncResult result)


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


在SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.KIS_Mill_WebServiceClientChannel.EndgetDGCustomersByRep(IAsyncResult result)


在SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.SalesRpt.KIS_Mill_SR.IKIS_Mill_WebService.EndgetDGCustomersByRep(IAsyncResult result)


at SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.OnEndgetDGCustomersByRep(IAsyncResult result)


在System.ServiceModel.ClientBase`1 .OnAsyncCallCompleted(IAsyncResult result)


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


在System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()


at SalesRpt.KIS_Mill_SR.getDGCustomersByRepCompletedEventArgs.get_Result()


at SalesRpt.Pages.Page.ws_getDGCustomersByRepCompleted(Object sender,getDGCustomersByRepCompletedEventArgs e)


...


我的Clientaccesspolicy文件如下。


<?xml version =" 1.0" encoding =" utf-8"?>


< access-policy>


<跨域访问>


< policy>


< allow-from>


< domain uri =" *" />


< / allow-from>


< p class = MsoNormal style ="margin:0cm 0cm 10pt"> < grant-to>


< resource path =" /" include-subpaths =" true" />


< / grant-to>


< / policy>


< / cross-domain-access>


< / access-policy>

解决方案

< blockquote> 希望这会有所帮助

http://whheuerer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx

Could someone please help me with the following problem, I am trying to use a web service to display records from a database located on my website with Mocha. The application works fine when tested on my desktop but I get the following error when testing it online. You can test it here  http://www.viewmypurchases.com/SalesRptTestPage.html  using two different address’s which give different errors.

System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.  Check InnerException for exception details. ---> System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://localhost/KIS_Mill_WebService.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__DisplayClass5.<EndGetResponse>b__4(Object sendState)

at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<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.SendAsyncResult.End(SendAsyncResult 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 SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.KIS_Mill_WebServiceClientChannel.EndgetDGCustomersByRep(IAsyncResult result)

at SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.SalesRpt.KIS_Mill_SR.IKIS_Mill_WebService.EndgetDGCustomersByRep(IAsyncResult result)

at SalesRpt.KIS_Mill_SR.KIS_Mill_WebServiceClient.OnEndgetDGCustomersByRep(IAsyncResult result)

at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

--- End of inner exception stack trace ---

at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()

at SalesRpt.KIS_Mill_SR.getDGCustomersByRepCompletedEventArgs.get_Result()

at SalesRpt.Pages.Page.ws_getDGCustomersByRepCompleted(Object sender, getDGCustomersByRepCompletedEventArgs e)

My Clientaccesspolicy file is as follows.

<?xml version="1.0" encoding="utf-8"?>

<access-policy>

<cross-domain-access>

<policy>

<allow-from>

<domain uri="*"/>

</allow-from>

<grant-to>

<resource path="/" include-subpaths="true"/>

</grant-to>

</policy>

</cross-domain-access>

</access-policy>

解决方案

Hope this helps

http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx


这篇关于Silverlight无法使用webservice Security Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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