首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Silverlight 4客户端访问SOAP web服务

从Silverlight 4客户端访问SOAP web服务
EN

Stack Overflow用户
提问于 2011-03-22 01:12:44
回答 2查看 3.5K关注 0票数 1

我正在做一个概念验证,我从我的Silverlight4客户端应用程序访问一个公共web服务。当我尝试调用this sample public web service时,我得到了以下错误:

代码语言:javascript
复制
An error occurred while trying to make a request to URI 'http://www.w3schools.com/webservices/tempconvert.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.

我只能访问具有这些策略的web服务吗?或者我只是没有在项目中正确配置ASMX服务吗?调用服务的代码如下:

代码语言:javascript
复制
   // Create
    var webServiceProxy = new TempConvert.TempConvertSoapClient();

    // Delegate
    webServiceProxy.FahrenheitToCelsiusCompleted += (s, args) =>
    {
        // Fail?
        if (args.Error != null)
        {
            // Message
            MessageBox.Show(string.Format("Something went wrong!\n\n{0}", args.Error.Message));
        }
        else
        {
            // Message
            MessageBox.Show(string.Format("50 f to c is {0}.", args.Result));
        }
    };

    // Call
    webServiceProxy.FahrenheitToCelsiusAsync("50");
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-03-22 02:37:27

最有可能的情况是,如果您是在您的机器上运行此应用程序,您将跨越域边界,并要求被调用站点具有适当的策略以从不同的域调用。

Microsoft has plenty of information about it,也可以在“silverlight跨域”中查找更多信息。

票数 2
EN

Stack Overflow用户

发布于 2012-07-05 21:16:03

当服务器收到带有url= /clientaccesspolicy.xml的GET时,请确保其响应为:

代码语言:javascript
复制
<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>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5381143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档