WCF service - data is discarded almost instantly according to size, despite large maximum values

I have a WCF web service with 1 functional web method that takes one string parameter. I have a WinForms application that references the WCF web service, and everything works on .NET 4.0.

The problem is that when I call the web method with too much data for string data (about 4 MB), this debugging of both the client and the server on my local computer (Win 7 Pro 64bit, IIS 7), I get the following error (internal exception, exception):

The request was aborted: the request was canceled.

An error (the request was aborted: the request was canceled.) Occurred while transmitting data over the HTTP channel.

When I run it on a production server, I get another message (stupid that I did not copy it), saying that something in the server lines might have interrupted the connection or the like.

If I reduce the data to half (2 MB), it works fine. I am disappointed that I configured all the configuration settings, reset IIS, rebooted my machine, but still remains.

The result is a web service validation code that validates the user as well, and then, as soon as he leaves the validation validation, the message above is sent back to the client. The stack trace when only .NET material is displayed in the verification method (my code), so there is no more my debugging code, 8 (.

On the server side, I have this in the web.config file:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
    <service name="MyNS.MyService" behaviorConfiguration="MyNS.MyServiceBehavior">
        <endpoint binding="wsHttpBinding" bindingConfiguration="httpWithMessageSecurity" contract="MyNS..MyService">
            <identity>
                <dns value="localhost"/>
            </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
</services>
<behaviors>
    <serviceBehaviors>
        <behavior name="MyNS.MyServiceBehavior">
            <serviceCredentials>
                <serviceCertificate findValue="Server" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyNS.Validators.MyServiceUserValidator, MyNS./>
            </serviceCredentials>
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
    </serviceBehaviors>
</behaviors>
<bindings>
    <wsHttpBinding>
        <binding name="httpWithMessageSecurity" 
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647">
            <readerQuotas
                maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647"
                maxArrayLength="2147483647"
                maxStringContentLength="2147483647"/>
            <security mode="Message">
                <message clientCredentialType="UserName"/>
            </security>
        </binding>
    </wsHttpBinding>
</bindings>

            

On the client side, I have this in app.config:

<system.serviceModel>
<bindings>
    <wsHttpBinding>
        <binding name="serviceHttpBinding"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 sendTimeout="01:00:00"
                 closeTimeout="00:00:20"
                 openTimeout="00:00:20"
                 receiveTimeout="00:20:00">
            <readerQuotas
                maxBytesPerRead="2147483647"
                maxNameTableCharCount="2147483647"
                maxArrayLength="2147483647"
                maxStringContentLength="2147483647"/>
            <security mode="Message">
                <message clientCredentialType="UserName" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
            </security>
        </binding>
    </wsHttpBinding>
</bindings>
<behaviors>
    <endpointBehaviors>
        <behavior name="clientServerBehaviour">
            <clientCredentials>
                <serviceCertificate>
                    <authentication certificateValidationMode="PeerOrChainTrust"/>
                </serviceCertificate>
            </clientCredentials>
        </behavior>
    </endpointBehaviors>
</behaviors>
<client>
    <endpoint address="http://mymachine/TheServices/Services/MyService.svc"
      binding="wsHttpBinding" bindingConfiguration="serviceHttpBinding"
      contract="DirectorySubmitService.IDirectorySubmitService" name="WSHttpBinding_IDirectorySubmitService">
        <identity>
            <dns value="Server" />
        </identity>
    </endpoint>
</client>

1: VS , WCF , : System.Web.HttpException: : System.Web.HttpRequest.GetEntireRawContent()

: System.ServiceModel.CommunicationException: : System.ServiceModel.Activation.HostedHttpRequestAsyncResult.GetInputStream()

CommunicationExceptions .., .

IIS, 30 , , , .

.

+3
1

, http.untime web.config, 50 , , , location = "MyService.svc" location = "Services/MyService.svc".

4 , - , .

Doh!

0

Source: https://habr.com/ru/post/1786165/


All Articles