简体   繁体   中英

WCF upload large images as wsHttpBinding

I've created a WCF Service to upload images. It works fine with images < 50KB or so but I get "The remote server returned an error: (400) Bad Request." with larger images. I've been looking for ages and tried lots of different things, including setting the maxRequestLength and several other settings.

On the client-side of things the web.config is picking it up as a basicHttpBinding and I'm after a wsHttpBinding (for the more up-to-date feature-set). If I manually change the the binding type to wsHttpBinding and change the corresponding options, I get a Unsupported Media Type error. Lookingin the WCF Test Client it shows the service as a basicHttpBinding too.

So my question is two-fold really.

  1. What do I need to do to allow my service to handle files > 50KB?
  2. What do I need to change for my service to be recognised as wsHttp instead of basicHttp?

Apologies if there is a question answering these - I have scoured stackoverflow and tried a few suggestions but it is possible I've missed it!

EDIT: As is always the way, I've managed to solve the wsHttpBinding issue now by fiddling around with the service web.config and manually changing the endpoint to wsHttpBinding. Still getting the large upload filesize issue though.

you will need to update your bindings in you web.config

eg this is how i did in my wcf restful service. i believe it will be very similar in your case as well

    <bindings>
          <webHttpBinding>
              <!-- buffer: 64KB; max size: 64MB -->
              <binding name="StreamedBinding" closeTimeout="00:01:00" openTimeout="00:01:00" 
                       receiveTimeout="00:10:00" sendTimeout="00:01:00" transferMode="Streamed" 
                       maxBufferPoolSize="67108864" maxBufferSize="65536" maxReceivedMessageSize="67108864">
              </binding>
          </webHttpBinding>
</bindings>

<service name="WCFRestFul.ApiRestful">
        <endpoint address="" binding="webHttpBinding"
                  bindingConfiguration="StreamedBinding" bindingName="StreamedBinding" 
                  contract="WCFRestFul.IApiRestful" behaviorConfiguration="web" />
 </service>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM