开发者

File Uploads to a WCF Service from ClientBase<T>

I'm currently working on a solution to upload and download files to a WCF service. The client is a class inheriting from ClientBase. I've read the MSDN article on streaming and links on StackOverflow and elsewhere, but I can't seem to figure out why I'm still getting a message about the Message size being too small. I have tested the solution so far with small files and it works.

The service is hosted in IIS 7.5

Here's the App.config from the Client application

<system.web>
    <httpRuntime maxRequestLength="67108864" />
</system.web>
<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingHttpBinding"
                     maxBufferSize="65536"
                     maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
            </binding>

        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost/UpdateService.svc"
                        binding="basicHttpBinding"
                        contract="IUpdateService"
                        name="updateServiceEndpoint"/>

    </client>
</system.serviceModel>

Here are the relevant sections in the server

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>

    <services>
        <service name="UpdateService" behaviorConfiguration="UpdateServiceBehavior">
                <endpoint binding="basicHttpBinding" bindingName="LargeFileStreamingWebHttpBinding" contract="IUpdateService"></endpoint>
                <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
        </service>
    </services>

    <behaviors>
        <serviceBehaviors>
                <behavior name="UpdateServiceBehavior" >
                        <serviceMetadata httpGetEnabled="true" />
                        <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
        </serviceBehaviors>
    </behaviors>

    <bindings>
        <basicHttpBinding>
                <binding messageEncoding="Mtom" transferMode="Streamed" name="LargeFileStreamingWebHttpBinding" 
                                 maxBufferSize="65536" 
                                 maxReceivedMessageSize="2147483647"
                                 />
        </basicHttpBinding>
    </bindings>
</system.serviceModel>

Additionally, I've added the following in on both server and client configs:

<system.web>
    <httpRuntime maxRequestLength="2147483647" />
</system.web>

This is how I'm instantiating the client

public class UpdateClien开发者_开发百科t : ClientBase<IUpdateService>, IUpdateService
{
    public UpdateClient() : base("updateServiceEndpoint") {}
}

So does have any ideas where I could be going wrong? Any help is appreciated.

-Thanks!


Found the answer - a very simple mistake, the client/endpoint entry was missing the bindingConfiguration attribute

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜