总结:用Silverlight调用sharepoint2010 webservice 出错

 

Description:

 

An error occurred while trying to make a request to URI 'http://localhost/_vti_bin/Lists.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.

 

Solution:

 

1.首先看看下面这两个Xml文件是否可以在浏览器中正常浏览;

http://localhost/crossdomain.xml

http://localhost/clientaccesspolicy.xml

默认情况下,是找不到这两个文件的,所以才出现了上述的错误。

 

2.把这两个文件拷到IIS下,这里要注意一下路径:

对于SharePoint网站,路径如下:

C:\inetpub\wwwroot\wss\VirtualDirectories\[your site port] ;

对于Asp.net网站,路径如下:

C:\inetpub\wwwroot

也就是说,把这两个文件放到WebService 所在的路径下。

 

3.这两个文件内容如下:

可以参考:

Network Security Access Restrictions in Silverlight

Clientaccesspolicy.xml

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

 

Crossdomain.xml

<?xml version="1.0"?>

<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">

<cross-domain-policy> <allow-http-request-headers-from domain="*" headers="*"/>

</cross-domain-policy>

 

 

参考文章:

1. http://forums.silverlight.net/forums/p/63112/345740.aspx

2. http://timheuer.com/blog/archive/2008/04/09/silverlight-cannot-access-web-service.aspx

转载于:https://www.cnblogs.com/LeimOO/archive/2010/12/02/1894626.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值