我正在做一个概念验证,从我的 Silverlight 4 客户端应用程序访问公共 Web 服务。当我尝试调用他的示例公共 Web 服务时,我收到以下错误:
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 服务?调用服务的代码如下:
// 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");