从同一主机上的子域访问时未找到WCF错误

时间:2012-10-26 16:41:46

标签: .net wcf silverlight

当我从本地计算机访问服务时,一切正常。但是,当我在子域网站上托管silverlight应用程序时,我没有得到任何响应。如果silverlight应用程序位于同一个子域中,或者位于不同的子域上,则无关紧要。没有任何反应。

这是我的服务的web.config文件:

    <?xml version="1.0"?>
    <configuration>

     <system.web>
      <compilation debug="true" targetFramework="4.0" />
     </system.web>
     <system.serviceModel>

    <services>
      <service behaviorConfiguration="Metadata" name="IVA_SL5_WCFservice.Service1">
        <endpoint address="http://subdomain.website.com/INA-inv_s/Service1.svc" binding="basicHttpBinding"
          bindingConfiguration="BasicHttpBinding_Service1" contract="IVA_SL5_WCFservice.Service1" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <timeouts closeTimeout="00:10:00" openTimeout="00:10:00" />
        </host>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_Service1" closeTimeout="00:25:00"           openTimeout="00:01:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Metadata">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
   <!-- <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> -->
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <!--
  <system.diagnostics>
    <sources>

以下是silverlight应用程序中的ClientConfig文件:

<configuration>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_Service1" closeTimeout="00:25:00"
                openTimeout="00:25:00" sendTimeout="00:25:00" maxBufferSize="2147483647"
                maxReceivedMessageSize="2147483647">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://subdomain.website.com/IVA-inv_s/Service1.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Service1"
            contract="IVA_Service.Service1" name="BasicHttpBinding_Service1" />
    </client>
</system.serviceModel>
</configuration>

我在Silverlight应用程序上调用这样的服务......

Service1Client client;
client = new IVA_Service.Service1Client("BasicHttpBinding_Service1");//"BasicHttpBinding_Service1");

我已经搞好了好几天了......请帮忙!

1 个答案:

答案 0 :(得分:0)

在声明服务时尝试添加绝对URI

new IVA_Service.Service1Client("BasicHttpBinding_Service1",
                            (new Uri(Application.Current.Host.Source,"../Service1.svc")).AbsoluteUri);