Silverlight Web服务中的问题 [英] problem in web service with Silverlight

查看:83
本文介绍了Silverlight Web服务中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我在Silverlight的Web服务中遇到问题,
我使用hello world创建了Web服务,并将此引用添加到vs 2010中的Silverlight应用程序中,并编写了此代码.

hi everyone i have problem in web service with Silverlight,
i created web service with hello world and added this reference to my Silverlight apps in vs 2010 and write this code.

private void button1_Click(object sender, RoutedEventArgs e)
       {
           //ServiceReference1.WebService1SoapClient s = new WebService1SoapClient();

           //s.HelloWorldAsync();
           //s.HelloWorldCompleted +=new EventHandler<helloworldcompletedeventargs>(s_HelloWorldCompleted);

           WebService1SoapClient s = new WebService1SoapClient();
         s.HelloWorldCompleted +=new EventHandler<helloworldcompletedeventargs>(s_HelloWorldCompleted);
         s.HelloWorldAsync();


       }
      void s_HelloWorldCompleted(object sender, HelloWorldCompletedEventArgs  e)
       {
           if (e.Error != null)
           {
               textBox1 .Text =e.error.Message;
           }
           else
           {
               textBox1 .Text = "Number of users: " + e.Result;
           }
       } </helloworldcompletedeventargs></helloworldcompletedeventargs>


并且在运行时出现错误

尝试向URI"http://ws.mywebsite.com/WebService1.asmx"发出请求时发生错误.这可能是由于尝试在没有适当的跨域策略或不适合SOAP服务的策略的情况下尝试以跨域方式访问服务.您可能需要联系服务的所有者以发布跨域策略文件,并确保它允许发送与SOAP相关的HTTP标头.此错误也可能是由于在Web服务代理中使用内部类型而不使用InternalsVisibleToAttribute属性而引起的.有关更多详细信息,请参见内部异常.

感谢您的帮助


and when run i have error

An error occurred while trying to make a request to URI ''http://ws.mywebsite.com/WebService1.asmx''. 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.

thanks for any help

推荐答案

您需要在根目录中放置客户端访问策略.
参见 [ ^ ].

如果您想了解更多有关它的信息,请参阅 Silverlight中的网络安全访问限制 [ ^ ].
You need to place a client access policy in the root directory.
See this[^].

If you want to read more about it - see Network Security Access Restrictions in Silverlight[^].


这篇关于Silverlight Web服务中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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