WCF upload large images as wsHttpBinding

廉价感情. 提交于 2020-01-06 05:16:12

问题


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.


回答1:


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

e.g. 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>


来源:https://stackoverflow.com/questions/6911817/wcf-upload-large-images-as-wshttpbinding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!