1

I have a WCF service with a method that accepts an array (of type Frame). Each element in the array includes an small array of elements (of type Shape) again where each element has two attributes. So, everything works fine. But now I have a message from the client to the server that consists of an array with 28 frames. With Wireshark I see, that the message is transmitted correctly. But in my .NET WCF service I don't get the call. But why? The bindings and reader-quotas are set to 5MB which should be enough.

The binding configuration:

    <bindings>
        <webHttpBinding>
            <binding name="default" transferMode="Streamed" maxReceivedMessageSize="5000000" maxBufferSize="5000000" maxBufferPoolSize="5000000">
                <readerQuotas maxStringContentLength="5000000" maxArrayLength="5000000" />
            </binding>
        </webHttpBinding>
    </bindings>

The WCF service definition:

[ServiceContract]
public interface IEditor
{
    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/WriteFrames", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
    void WriteFrames(Frame[] frames, int animationSpeed);
}

Type descriptions:

  1. Type: Frame
    • Array: Shapes
      • Shape 1
      • Shape 2
      • ...
  2. Type: Shape
    • Array: Points
      • Point 1
      • Point 2
      • ...
  3. Type: Point
    • X
    • Y

The service is hosted as a singleton. See static Create method.

sealed class EditorHost : ServiceHost
{
    public EditorHost()
        : base(typeof(Editor))
    {
    }

    public EditorHost(params Uri[] baseAddresses)
        : base(typeof(Editor), baseAddresses)
    {
    }

    public EditorHost(Editor singleton, params Uri[] baseAddresses)
        : base(singleton, baseAddresses)
    {
    }

    internal static EditorHost Create(out Editor editor, int port = 8732)
    {
        var uri = new Uri(string.Format("http://localhost:{0}/", port));
        editor = new Editor();
        var host = new EditorHost(editor, uri);
        return host;
    }
}
Matthias
  • 5,574
  • 8
  • 61
  • 121

1 Answers1

0

I found the problem in this post. My binding configuration was correct but it was not correctly applied to my endpoint. Using the attribute bindingConfiguration on the endpoint worked.

I found the problem using the network sniffer from Colasoft which then showed me that the package said "too long" in the end. Therefore the JSON content was destroyed (interrupted) and not correctly deserialized. I just wonder that .NET did not throw any exception.

        <webHttpBinding>
            <binding name="webDefault" transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
                <readerQuotas
                    maxStringContentLength="2147483647"
                    maxArrayLength="2147483647"
                     maxDepth="2147483647"
                     maxBytesPerRead="2147483647"
                     maxNameTableCharCount="2147483647"
                    />
            </binding>
        </webHttpBinding>

        <service name="WebService.EditorService.Editor" behaviorConfiguration="BehConfig">
            <endpoint address="/JSON" binding="webHttpBinding" bindingConfiguration="webDefault" contract="WebService.EditorService.IEditor" behaviorConfiguration="web" />
        </service>
Community
  • 1
  • 1
Matthias
  • 5,574
  • 8
  • 61
  • 121