我有一个带有wcf服务自我的silverlight应用程序。当我在Windows Server 2008上的iis7上发布带有服务的应用程序时,我无法在我的应用程序中看到来自服务的任何数据(服务没有被调用)。虽然调试应用程序我可以看到来自servcie(sql server表数据)的数据。当我在本地系统上发布相同的应用程序,即windows7上的IIS-7时,我能够在网络中的任何系统上访问服务和数据以及发布的系统。 我已经在iis7上做了所有可能的设置,我发现并且服务的url在任何地方都是正确的(动态生成),因为我已经在Windows 7中的iis 7上成功发布了它,只有应用程序在iis上发布时才访问wcf Windows服务器。 此外,我已经浏览了所有可用的帖子,但没有找到确切的解决方案。 我所做的iis 7和wcf的设置是
这是我的一段代码,我在那里动态生成服务端点url。
Try
busyIndicator.IsBusy = True
mService.Endpoint.Address = New EndpointAddress(DynamicEndpointHelper.ResolveEndpointUrl(mService.Endpoint.Address.Uri.ToString(),
App.Current.Host.Source.ToString()))
mService.GetProjectNamesAsync()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Public Class DynamicEndpointHelper
' Put the development server site URL including the trailing slash
' This should be same as what's set in the Dropthings web project's
' ' properties as the URL of the site in development server
Private Const BaseUrl As String = "http://localhost:1632/"
Public Shared Function ResolveEndpointUrl(endpointUrl As String, xapPath As String) As String
Dim baseUrl__1 As String = xapPath.Substring(0, xapPath.IndexOf("ClientBin"))
Dim relativeEndpointUrl As String = endpointUrl.Substring(BaseUrl.Length)
Dim dynamicEndpointUrl As String = baseUrl__1 & relativeEndpointUrl
Return dynamicEndpointUrl
End Function
End Class
web.config部分:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="testing.Web.Service1.basicHttpBinding" >
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="testing.Web.Service1">
<endpoint address="" binding="basicHttpBinding" contract="testing.Web.Service1" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
ServiceReference.ClientConfig part
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1632/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service1" contract="sr_service1.Service1"
name="BasicHttpBinding_Service1" />
</client>
</system.serviceModel>
</configuration>
答案 0 :(得分:0)
sivlerlight应用程序尝试调用的端点地址在ServiceReference.clientconfig中定义为:http://localhost:1632/Service1.svc。我假设这不是您要使用的实际部署地址。有关如何动态分配服务端点地址,请参阅此article。