WCF TestClient set fixed configuration file

1.Open WcftestClient.exe,option cancel  Always regenerate configuration when starting services;

image

 

2.New folder WCFTest under C disk;

 

3.Open Developer Command Format for VS and run below command to set the fixed configuraton folder;

"C:\Program Files\Microsoft Visual Studio\18\Enterprise\Common7\IDE\WcfTestClient.exe" /ProjectPath "C:\WCFTest"

image

 

4.Open WcfTestClient.exe;

5.Open C:\WCFTest\6ef9bab2-dea1-4301-ba99-03a66011eeed\client.dll.config and set as below;

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding> 
                <binding name="BasicHttpBinding_IBookService"
                         sendTimeout="00:05:00"
                         maxReceivedMessageSize="2147483647"
                         maxBufferSize="2147483647"
                         maxBufferPoolSize="2147483647">
                    <readerQuotas
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxDepth="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647"/>
                </binding>
            </basicHttpBinding>
        </bindings>
 
        <client>
            <endpoint 
                address="http://localhost:53768/BookService.svc" 
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IBookService" 
                contract="IBookService"
                name="BasicHttpBinding_IBookService" />
        </client>
    </system.serviceModel>
</configuration>

 

6.Of course I have to set the wcf service webconfig as below to allow 214748367 bytes at most.

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

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.8" />
    <httpRuntime targetFramework="4.8"/>
  </system.web>
  <system.serviceModel>
      <bindings>
          <basicHttpBinding>
              <binding name="BasicHttpBinding_IBookService"
                       maxReceivedMessageSize="2147483647"
                       maxBufferSize="2147483647"
                       maxBufferPoolSize="2147483647"
                       >
                  <readerQuotas
                      maxDepth="2147483647"
                      maxArrayLength="2147483647"
                      maxStringContentLength="2147483647"
                      maxBytesPerRead="2147483647"
                      maxNameTableCharCount="2147483647"
                      />
              </binding>
          </basicHttpBinding>
      </bindings>

      <services>
          <service name="WcfService5.BookService">
              <endpoint address=""
                        binding="basicHttpBinding"
                        bindingConfiguration="BasicHttpBinding_IBookService"
                        contract="WcfService5.IBookService"/>
              <endpoint address="mex"
                        binding="mexHttpBinding"
                        contract="IMetadataExchange"/>
          </service>
      </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

 

image

 

 

 

image

 

posted @ 2026-05-16 16:12  FredGrit  阅读(12)  评论(0)    收藏  举报