2014-01-29 80 views
1

我搜索了這麼多的論壇,但我很困惑,我必須在web.config文件中做什麼設置,我必須做什麼?我有兩個應用程序獨立1.Asp.net應用程序2.WCF服務應用程序;我在我的Asp.net應用程序中添加了服務引用。這些應用程序不在IIS上託管,我正在本地機器上測試它。請爲我提供指導,將上傳的文件傳遞給服務應用程序。WCF:遠程服務器返回錯誤:(400)錯誤的請求

Asp.net應用程序的web.config

<configuration> 
<configSections> 
</configSections> 
<system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
      <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> 
      <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
      <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
      <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     </assemblies> 
    </compilation> 
</system.web> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IWCF" closeTimeout="00:01:00" 
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
      useDefaultWebProxy="true"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <security mode="None"> 
        <transport clientCredentialType="None" proxyCredentialType="None" 
        realm="" /> 
        <message clientCredentialType="UserName" algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost:7147/WCFService.svc" binding="basicHttpBinding" 
     bindingConfiguration="BasicHttpBinding_IWCF" contract="HostedWCF.IWCF" 
     name="BasicHttpBinding_IWCF" /> 
    </client> 
</system.serviceModel> 

服務應用程序的Web.config

<configuration> 
<connectionStrings> 
    <!--<add name="DPOConnectionString" connectionString="Data Source=s15346491\SQLEXPRESS;Database=DatabaseName;Uid=UserID;Password=password;"/>--> 
    <add name="ConnectionString" connectionString="Data Source=SWAPNIL-PC;Initial Catalog=PayrollNet;Integrated Security=True" /> 
</connectionStrings> 
<appSettings> 
    <add key="LogoPath" value="C:\Users\HARSH12\Desktop\New Conversion 26-7-2013\ConstructionApplication\CMSERPService\ErrorLog\ErrorLog.txt" /> 
</appSettings> 
<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
</system.web> 
<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior> 
       <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
       <serviceMetadata httpGetEnabled="true" /> 
       <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <defaultDocument> 
     <files> 
      <add value="WCFService.svc" /> 
     </files> 
    </defaultDocument> 
</system.webServer> 

+0

你的'http:// localhost:7147/WCFService.svc'是否正常運行?檢查它在瀏覽器 –

+0

是的,它工作正常 – user3021739

回答

1

試試這個

<bindings> 
    <basicHttpBinding> 
     <binding name="BasicHttpBinding_IWCF" closeTimeout="00:01:00" 
     openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" 
     allowCookies="false" bypassProxyOnLocal="false" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
     useDefaultWebProxy="true"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /> 
      <security mode="None"> 
       <transport clientCredentialType="None" proxyCredentialType="None" 
       realm="" /> 
       <message clientCredentialType="UserName" algorithmSuite="Default" /> 
      </security> 
     </binding> 
    </basicHttpBinding> 
</bindings> 
+0

好吧,但在其中web.config我必須添加服務器應用程序web.config或Asp.net應用程序web.config – user3021739

+0

做完所需的更改後,我在WCFTestClient上測試它,但它顯示我配置像Asp.net應用程序web.config(上面給出) – user3021739

+0

添加此應用程序web.config –

相關問題