none
IMAGE FILE UPLOAD USING WCF REST WEB SERVICE

    Question

  • Hi Everyone,

    I tried to upload an image into IIS Server  from a WPF application using a REST Architecture in WCF.

    Following are the steps created for doing this

    1) Created a WCF library and used that dll inside my client side application and Web Service Site as a refrence. Created a WebInvoke Method=POST for uploading a file by passing Image byete array adn filename as parameters to the method.
    2) Created a WCF Service...deleted the default Iservice.cs and Service.cs as I am refreiing teh dll from the Service library. I am using Factory attribute inisde my Service.svc markup tag and deleted the service model tag from the Web.config. This will ensure that I can use REST .

    3) Inside my client application in the upload click event  I am refreeing System.Servicemodel.web so that I can use Web channel factory which uses the dll from the library for its declaration. I created a channel and by using the channel.Upload(filename, byte[] filecontents)..I am uploading the image from the client.

    The point is I could upload a small 4 kb image file succesffully into my external IIS server. But if I am tryng to upload an image which has size more tha 5kb i am gettingg 400 bad request error.

    I tried to keep httpruntime tag inside web,config of WebService but that didnot help. I am uanble to use binding because I am using Facory attribute in Svc file markup so that I am deleting the Service.model tag inside web.config to make it REST ful webservice.

    If you think i made any mistake how can a 4kb file uploaded into the server.

    Should I change any more settings. Sometimes the innerexcpoetion and stacktrace show me the error that ther is no enpoint found at the specified address.

    Can anyonle please help how shoudl I move forward in implmenting the file uplaod for any size.
    Tuesday, November 24, 2009 12:43 AM

Answers

  • Hi,

    Try to increase your binding elements' size related to:

    maxReceivedMessageSize ="50000000" maxBufferPoolSize="50000000" >
    <readerQuotas maxDepth="500000000"
    maxArrayLength="500000000" maxBytesPerRead="500000000"
    maxNameTableCharCount="500000000" maxStringContentLength="500000000"/>

    Thanks
    Binze

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, November 27, 2009 8:55 AM
  • Hi Malkum,

    Have you tried the binding quota settings Binze mentioned? If you have enlarged the ASP.NET <httpRuntime> request length, then we we left is the WCF's message quotas. Here is a former thread which also discusses on this:

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/70ced533-23bb-458d-b50e-22fb7eccef47


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bin-ze Zhao Monday, November 30, 2009 6:30 AM
    Monday, November 30, 2009 2:47 AM
    Moderator

All replies

  • Hi,

    Try to increase your binding elements' size related to:

    maxReceivedMessageSize ="50000000" maxBufferPoolSize="50000000" >
    <readerQuotas maxDepth="500000000"
    maxArrayLength="500000000" maxBytesPerRead="500000000"
    maxNameTableCharCount="500000000" maxStringContentLength="500000000"/>

    Thanks
    Binze

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, November 27, 2009 8:55 AM
  • Hi Malkum,

    Have you tried the binding quota settings Binze mentioned? If you have enlarged the ASP.NET <httpRuntime> request length, then we we left is the WCF's message quotas. Here is a former thread which also discusses on this:

    http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/70ced533-23bb-458d-b50e-22fb7eccef47


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Bin-ze Zhao Monday, November 30, 2009 6:30 AM
    Monday, November 30, 2009 2:47 AM
    Moderator