我正在尝试从 Silverlight 应用程序调用 WCF Web 服务(我开发的)。由于某种原因,Silverlight 应用程序不会对服务进行 http soap 调用。我知道这一点是因为我正在使用 Fiddler 嗅探所有 http 流量(而且它不是 localhost 调用)。
这是我在与 WCF 相关的服务器中的配置:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" binding="basicHttpBinding" contract="Service"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
以及 silverlight 应用程序中的 ServiceReferences.ClientConfig 文件(我使用的是 beta 2):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Service" maxBufferSize="65536"
maxReceivedMessageSize="65536">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://itlabws2003/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service" contract="Silverlight_organigram.DataService.Service"
name="BasicHttpBinding_Service" />
</client>
</system.serviceModel>
这是调用服务的silverlight方法,为了完整性,我粘贴了整个方法,lambda是为了使调用同步,我已经调试过了,在client.GetPersonsAsync()行之后,Fiddler没有显示任何消息传送到服务器。
public static List<Person> GetPersonsFromDatabase()
{
List<Person> persons = new List<Person>();
ServiceClient client = new ServiceClient();
ManualResetEvent eventGetPersons = new ManualResetEvent(false);
client.GetPersonsCompleted += new EventHandler<GetPersonsCompletedEventArgs>(delegate(object sender, GetPersonsCompletedEventArgs e)
{
foreach (DTOperson dtoPerson in e.Result)
{
persons.Add(loadFromDto(dtoPerson));
}
eventGetPersons.Set();
});
client.GetPersonsAsync();
eventGetPersons.WaitOne();
return persons;
}
有人对我如何解决这个问题有任何建议吗?