Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Problem with http post through proxy

  1. #11

    Default

    Hello,

    I have refactored the RemoteClient support for application/x-www-form-urlencoded forms so that it correctly submits the posted paramaters.

    I used something very similar to your test case:
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
          <title>Proxy Test</title>
       </head>
       <body>
          <form method="post" action="${url.context}/proxy/alfresco-admin/sample/args" accept-charset="UTF-8">
             <div>
                <input type="text" name="firstname" value="Charles"/>
                <input type="text" name="lastname" value="Dickens"/>
                <input type="submit"/>
             </div>
          </form>
       </body>
    </html>
    and I created a multipart/form-data version of the same test with a file upload element:
    Code:
    <html xmlns="http://www.w3.org/1999/xhtml">
       <head>
          <title>Proxy Test</title>
       </head>
       <body>
          <form method="post" action="${url.context}/proxy/alfresco-admin/sample/args" enctype="multipart/form-data" accept-charset="UTF-8">
             <div>
                <input type="text" name="firstname" value="Charles"/>
                <input type="text" name="lastname" value="Dickens"/>
                <input type="file" name="fileupload"/>
                <input type="submit"/>
             </div>
          </form>
       </body>
    </html>
    Both tests now work correctly, I used your sample args webscript at the backend also.

    rev 408

    Thanks,

    Kevin

  2. #12
    Join Date
    Aug 2004
    Location
    Amsterdam, The Netherlands
    Posts
    14

    Default

    Hi Kev,

    Thank you very much for your help. I tried to run the upload, but still receive a 400 error from the sample/upload backend script (http://wiki.alfresco.com/wiki/Web_Sc...es#File_Upload) that I use to test the multipart data.

    Have you been able to post the multipart form to the sample/upload backend webscript, or do I need to use a different approach to retrieve the file data in the backend?

    Kind regards,

    Bas

  3. #13

    Default

    Hi,

    That is exactly the sample upload webscript I used to test the backend of multi-part form file upload - so yes it should work

    The only changes I made to your web-tier sample, were to set the form to multipart:
    Code:
    enctype="multipart/form-data"
    and obviously change the field names to match those expected by the backend:
    Code:
                <input type="text" name="title" value="the file title"/>
                <input type="text" name="desc" value="the file description"/>
                <input type="file" name="file"/>
    Then you will see the result:
    Code:
    Alfresco  	Upload Web Script Sample
    	Alfresco Community v3.3.0 (beta @build-number@)
    	
    	Uploaded upload9_01-gold-bar.jpg of size 76,151.
    So the key point here is that multipart must be set on your upload form if it is to be used to transfer file content - that is the only mechanism supported for binary uploads, and the field names expected by the destination web-script must match those in your source form.

    Cheers,

    Kev

  4. #14
    Join Date
    Aug 2004
    Location
    Amsterdam, The Netherlands
    Posts
    14

    Default

    In that case I must be doing something wrong since I keep receiving the following response from the backend:

    ========
    Alfresco Web Script Status 400 - Bad Request

    The Web Script /alfresco/service/sample/upload has responded with a status of 400 - Bad Request.

    400 Description: Request sent by the client was syntactically incorrect.

    Message: Uploaded file cannot be located in request
    Server: Alfresco Community v3.3.0 (2765) schema 4.009
    Time: 28-mei-2010 16:12:38

    Diagnostics: Inspect Web Script (upload.post)
    ========

    I am using Spring Surf revision 414 on the frontend (did an svn update, mvn clean and install for surf), created a quick start application and modified surf.xml according to the attached file and added the upload.get.desc.xml and upload.get.html.ftl (see attachment).

    On the backend I use Alfresco Community 3.3 with the upload post script from the sample webscripts page.

    Any idea what the difference might be?

    Kind regards,

    Bas
    Attached Files Attached Files

  5. #15
    Join Date
    May 2010
    Posts
    2

    Default

    have just the same problem. thank you for trying to help us

  6. #16
    Join Date
    Jun 2010
    Posts
    2

    Default Success.

    Hi Bas,

    I installed your upload web script in to a sample Surf webapp built a few weeks ago. I then uploaded your back-end web scripts into Alfresco and tested an upload. I am running a HEAD build of Alfresco, but the web scripts that were installed were the ones you provided.

    The upload failed with the same error that you reported -
    400 Description: Request sent by the client was syntactically incorrect.

    I then pulled down the latest Spring Surf libs and built the test application \trunk\spring-surf-applications\spring-surf-application-quickstart and dropped this into my Tomcat server. I added just the upload freemarker template (replacing the home page).

    The upload then succeeds. My test webapp can be found here - http://www.benh.co.uk/springsurf.zip

    Let me know how your testing goes.

    Regards, Ben.

  7. #17
    Join Date
    Aug 2004
    Location
    Amsterdam, The Netherlands
    Posts
    14

    Default your sample works

    Hi Ben,

    Thank you very much for your support. Your code is working properly both for Alfresco Community 3.3 and Enterprise 3.2. I now have a reference that will help me to solve the issue.

    Thanks again.

    Kind regards,

    Bas

  8. #18

    Default

    Great news! Thanks.

    Kev

  9. #19
    Join Date
    Jun 2010
    Posts
    2

    Default

    Thanks Bas!

    Regards, Ben.

  10. #20
    Join Date
    Aug 2004
    Location
    Amsterdam, The Netherlands
    Posts
    14

    Default web-application-config.xml

    I guess I found out why I was unable to upload even after Kev's updates to the Surf code although I used the latest snapshot (revision 416). The web-application-config.xml contains some changes. When I commented out the following bean declaration related to the multipart handler the upload works properly:

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.C ommonsMultipartResolver">
    <property name="maxUploadSize" value="10000000"/>
    </bean>

    The application I used to test the code updates done by Kev used the latest libraries, but I never updated the Roo add-on, so the quick start application still had the old configuration in web-application-config.xml.

    Thanks again Kev and Ben for your help.

    Bas

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •