【发布时间】:2009-09-15 15:14:57
【问题描述】:
使用 Silverlight 3、Windows XP、IIS 5.1,我编写了一个小应用程序,它使用调用服务器的通道方法,而不是按照这篇 MSFT 文章的“添加服务引用”。
在 VS 2008 的开发计算机上使用地址 localhost 加上端口号运行应用程序时,应用程序打开并且对服务器的调用工作。当我将地址更改为计算机名 dellnov2006 并将应用程序发布到 IIS 时,应用程序打开,但对 Web 服务的调用不起作用。
查看 Web Dev Helper 中的调用,我看到该应用正在尝试调用服务文件 http://dellnov2006/Service1.svc,并收到 404 错误。
到目前为止,我已经:
-在 IIS 中将 .svc 类型映射到 aspnet-isapi.dll - 运行实用程序 CleanIISScriptMaps -运行aspnet_regiis.exe -i --enable
任何帮助将不胜感激 - 我在这方面的想法已经不多了。
--
这里是对服务器的回调,以及Service1.svc文件的内容:
private void Button_Click(object sender, RoutedEventArgs e)
{
// create a custom binding that uses HTTP and binary encoding
var elements = new List<BindingElement>();
elements.Add(new BinaryMessageEncodingBindingElement());
elements.Add(new HttpTransportBindingElement());
var binding = new CustomBinding(elements);
// create a channel factory for the service endpoint configured
// with custom binding
//var cf = new ChannelFactory<IService1>(binding,
// new EndpointAddress("http://localhost:1042/Service1.svc"));
var cf = new ChannelFactory<IService1>(binding,
new EndpointAddress("http://dellnov2006/Service1.svc"));
// save the syncronized context for the ui thread
uiThead = SynchronizationContext.Current;
// open the channel
IService1 channel = cf.CreateChannel();
// invoke the method asychrnoously
channel.BeginGetPerson(4, GetPersonCallback, channel);
}
这里是 svc 文件的内容,它们的价值:
<%@ ServiceHost Language="C#" Debug="true" Service="SilverlightChannelApp1.Web.Service1" CodeBehind="Service1.svc.cs" %>
非常感谢 迈克·托马斯
【问题讨论】:
标签: wcf silverlight