发布Silverlight的问题在iis7和Windows Server 2008上启用了wcf服务

时间:2015-03-23 06:47:43

标签: wcf silverlight iis-7 publish windows-server-2008-r2

我有一个带有wcf服务自我的silverlight应用程序。当我在Windows Server 2008上的iis7上发布带有服务的应用程序时,我无法在我的应用程序中看到来自服务的任何数据(服务没有被调用)。虽然调试应用程序我可以看到来自servcie(sql server表数据)的数据。当我在本地系统上发布相同的应用程序,即windows7上的IIS-7时,我能够在网络中的任何系统上访问服务和数据以及发布的系统。 我已经在iis7上做了所有可能的设置,我发现并且服务的url在任何地方都是正确的(动态生成),因为我已经在Windows 7中的iis 7上成功发布了它,只有应用程序在iis上发布时才访问wcf Windows服务器。 此外,我已经浏览了所有可用的帖子,但没有找到确切的解决方案。 我所做的iis 7和wcf的设置是

  • -aspnet_iisreg.exe(已安装)
  • - Windows功能中的所有必需设置都会打开和关闭。
  • -on iis,为所需用户设置了所有权限。
  • - 设置以mime类型和处理程序映射完成。
  • - 我可以在没有错误的情况下成功浏览wcf服务,并且在从应用程序调用服务时使用相同的URL。

这是我的一段代码,我在那里动态生成服务端点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>

1 个答案:

答案 0 :(得分:0)

sivlerlight应用程序尝试调用的端点地址在ServiceReference.clientconfig中定义为:http://localhost:1632/Service1.svc。我假设这不是您要使用的实际部署地址。有关如何动态分配服务端点地址,请参阅此article

相关问题