none
Rec. Bad Request 400 Streaming WCF RRS feed

  • Question

  • Hi All,

    I've got a slightly more unique situation. I can have a configuration file on the server, but the client can not. Currently I can't get anything to work, and I seem to be regressing please someone save me.

    Earlier today, I was getting some communication from the server to the client but only 400 - 750KB would transfer, then the client would spit back: Bad Request 400.

    I checked the server, and it seemed to finish the function as if there was no data on the stream. Therefore I have tried adding the Filesize to the headers with the hopes on determining if there is more data left on the stream to wait. 

    I've killed more hours on this than I'd like to admit. Is there anyone with any Insight?

    Server:

         <behaviors>
           <serviceBehaviors>
             <behavior name="FileUploadServiceBehavior">
               <serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" suppressAuditFailure="true" />
               <serviceMetadata httpGetEnabled="True" httpsGetEnabled="False" />
               <serviceDebug includeExceptionDetailInFaults="True" />
             </behavior>
           </serviceBehaviors>
         </behaviors>
          <bindings>
            <basicHttpBinding>
              <binding name="FileUploadServiceBinding"
                       transferMode="Streamed"
                       messageEncoding="Mtom"
                       maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                       closeTimeout="00:10:00" openTimeout="00:10:00"
                       receiveTimeout="00:10:00" sendTimeout="00:10:00">
                <security mode="None">
                  <transport clientCredentialType="None" />
                </security>
              </binding>
            </basicHttpBinding>
          </bindings>

    Client:

                string sEndpoint = DynServiceUriLocation;
                System.ServiceModel.EndpointAddress endPointAddress = new System.ServiceModel.EndpointAddress(sEndpoint);
    
                BasicHttpBinding wsBinding = new BasicHttpBinding();
                wsBinding.TransferMode = TransferMode.Streamed;
                wsBinding.MessageEncoding = WSMessageEncoding.Mtom;
                wsBinding.MaxBufferSize = 2147483647;
                wsBinding.MaxReceivedMessageSize = 2147483647;
                wsBinding.CloseTimeout = new TimeSpan(0, 10, 0);
                wsBinding.OpenTimeout = new TimeSpan(0, 10, 0);
                wsBinding.SendTimeout = new TimeSpan(0, 10, 0);
                wsBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
                wsBinding.Security.Mode = BasicHttpSecurityMode.None;
                wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;

    I am transferring:

        [MessageContract]
        public class UploadRequest
        {
            [MessageHeader(MustUnderstand = true)]
            public string FileName { get; set; }
    
            [MessageHeader(MustUnderstand = true)]
            public int FileSize { get; set; }
    
            [MessageBodyMember(Order = 1)]
            public Stream Stream { get; set; }
        }
    
        [MessageContract]
        public class UploadResponse
        {
            [MessageBodyMember(Order = 1)]
            public bool UploadSucceeded { get; set; }
        }



    Tuesday, April 16, 2013 11:23 PM

Answers

  • Sorry for this delayed response.

    Enable WCF Tracing thus:

      <system.diagnostics>
        <trace autoflush="true" />
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="traceListener"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData="c:\log2\Traces.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    Run your app and hit the error.

    Open the Traces.svclog double click your error and post the details.

    I hope this helps.

    • Marked as answer by BlndLeadingDef Thursday, April 18, 2013 11:19 PM
    Thursday, April 18, 2013 3:21 PM

All replies

  • I think you need to define your service endpoint explicitly and apply the binding configuration to it. Instead of relying on the simplified configuration.

        <services>
          <service name="ServiceName" behaviorConfiguration="">
            <endpoint address="" binding="basicHttpBinding"
               bindingConfiguration="FileUploadServiceBinding" contract="YourContract"
              name="SomeName" />
          </service>
        </services>

    Wednesday, April 17, 2013 2:00 PM
  • I'm sorry imadotnetter, I forgot to include that section in my first post. I do have that:

        <services>
          <service behaviorConfiguration="FileUploadServiceBehavior" name="XX.XX">
            <endpoint address="" binding="basicHttpBinding" contract="XX.IXX" bindingConfiguration="FileUploadServiceBinding"/>
          </service>
        </services>

    Wednesday, April 17, 2013 2:06 PM
  • perhaps try adding this inside the binding:

    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                            maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                            maxNameTableCharCount="2147483647" />

    Wednesday, April 17, 2013 2:47 PM
  • imadotnetter,

    I want you to know I appreciate your attempts that helping me solve this problem.

    Unfortunately, I must say this morning I did end up adding that section, but there was no change.

    Do you know a way to enable tracing via code, rather than a config file. I'm not in the position to create a configuration file and must run the client specifically from code.


    Edit: I just read that isn't possible. I have created a separate application in which I can edit the configuration and have enabled tracing. There doesn't seem to be an error on that end either. How does one diagnose these error 400's?! What the hell is with this complexity?
    Wednesday, April 17, 2013 2:51 PM
  • Sorry for this delayed response.

    Enable WCF Tracing thus:

      <system.diagnostics>
        <trace autoflush="true" />
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true">
            <listeners>
              <add name="traceListener"
                  type="System.Diagnostics.XmlWriterTraceListener"
                  initializeData="c:\log2\Traces.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    Run your app and hit the error.

    Open the Traces.svclog double click your error and post the details.

    I hope this helps.

    • Marked as answer by BlndLeadingDef Thursday, April 18, 2013 11:19 PM
    Thursday, April 18, 2013 3:21 PM
  • Hi imadotnetter,

    Two things. 1) I read somewhere that there's some bugs in streamed transfer when running through ASP.NET in .NET 4.0 and IIS 7. 2) I gave up after 3 days of attempting to solve this and developed a REST service hosted in a self serving application.

    So is this a solution? No. Unfortunately not. But I do want to thank you for writing back to me. I did end up enabling the Tracing but I found out it's *not* possible to enable tracing in code only and not through a configuration file.

    I'm accepting your last post as an answer as thanks for being the only kind soul to reply. Good luck in your endeavors.

    BLD

    Thursday, April 18, 2013 11:19 PM