在 Silverlight 4 应用程序中使用 WCF 库 [英] Consume WCF library in Silverlight 4 application

查看:25
本文介绍了在 Silverlight 4 应用程序中使用 WCF 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试向 URI 发出请求时发生错误:

An error occurred while trying to make a request to URI:

'http://localhost:8732/Design_Time_Addresses/WCF/Service1/'.这个可能是由于尝试

'http://localhost:8732/Design_Time_Addresses/WCF/Service1/'. 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

不适合 SOAP 服务的策略.您可能需要联系服务的所有者

policy that is unsuitable for SOAP services. You may need to contact the owner of the service

发布跨域策略文件并确保它允许与 SOAP 相关的 HTTP 标头是

to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be

发送.这个错误也可能是在web中使用内部类型引起的没有

sent. This error may also be caused by using internal types in the web service proxy without

使用 InternalsVisibleToAttribute 属性.请看内页更多的例外

using the InternalsVisibleToAttribute attribute. Please see the inner exception for more

细节.

wcf 返回结果时出现错误

the error appears when result returned from the wcf

我通过控制台、网站、win 表单使用了这​​个 wcf 并且它工作正常

I consumed this wcf via console, website, win forms and it works properly

我在 WCF 库中使用了 2 个 xml 文件:

I use 2 xml files in the WCF library :

  1. clientaccesspolicy.xml
  2. crossdomain.xml

推荐答案

它曾经让我的大脑也受到伤害.

It used to make my brain hurt too.

我发现我需要这个文件:

I figured out for my use I needed this file:

<?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>

命名为clientaccesspolicy.xml

named clientaccesspolicy.xml

诀窍是它必须位于您的网络服务器的根目录.也就是说,您需要能够浏览文件.在您的情况下位于:

The trick is that is has to be at the root of your web server. That being said you need to be able to browse the file. In your case located at:

http://localhost:8732/clientaccesspolicy.xml

如果你看不到文件,silverlight 总是会抱怨,男孩会尽可能地抱怨!

If you cannot see the file silverlight will always complain and boy does it complain whenever it can!

我应该指出我的策略文件没有限制,所以明智地使用它.

I should point out that my policy file is not restrictive, so use it wisely.

这篇关于在 Silverlight 4 应用程序中使用 WCF 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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