Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4756

Standalone Axis2 server cannot handle multipart http requests

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.5.1, nightly
    • Fix Version/s: None
    • Component/s: kernel, transports
    • Labels:
      None

      Description

      When running a standalone Axis2 server and a multipart Http request is received, the org.apache.axis2.builder.MultipartFormDataBuilder will throw an exception: "Cannot create DocumentElement without HttpServletRequest".

      Reason for this is that the Axis2 Http server wraps the incoming http request into an AxisHttpRequest and there is no HttpServletRequest available.

      1. patch.txt
        18 kB
        Detelin Yordanov
      2. MultiPartHttpTest.zip
        16 kB
        Detelin Yordanov
      3. FileUploadService.aar
        4 kB
        Detelin Yordanov

        Issue Links

          Activity

          Hide
          detyo Detelin Yordanov added a comment - - edited

          This can be solved by providing custom implementation of org.apache.commons.fileupload.RequestContext that supports handling of an AxisHttpRequest.

          Afterwards, the following simple modifications will do the trick:

          1. When serving a request, the HTTPWorker will need to set the AxisHttpRequest in the MC
          2. The MultipartFormDataBuilder will check for an AxisHttpRequest if it does not find an HttpServletRequest and will use the custom "AxisHttpRequestContext" implementation to extract the multipart parameters.

          I created a patch, but it was mean for Axis2 1.4.1 and it is not very appropriate for Axis2 1.5 since the http transport classes are moved to a separate module and the MultipartFormDataBuilder is not able to reference them anymore.
          As a workaround I provided a new MultipartFormDataBuilder in the http transport module, which extends the one in axis2 kernel.

          If running Axis2 standalone , users will need to specify that one in the axis2.xml, e.g.:

          <messageBuilders>
          ...
          <messageBuilder contentType="multipart/form-data" class="org.apache.axis2.transport.http.MultipartFormDataBuilder"/>
          </messageBuilders>

          Is should be possible to use some factory mechanism to avoid having two MultipartFormDataBuilder implementations. But this would require some design changes which I will leave to you.

          Show
          detyo Detelin Yordanov added a comment - - edited This can be solved by providing custom implementation of org.apache.commons.fileupload.RequestContext that supports handling of an AxisHttpRequest. Afterwards, the following simple modifications will do the trick: 1. When serving a request, the HTTPWorker will need to set the AxisHttpRequest in the MC 2. The MultipartFormDataBuilder will check for an AxisHttpRequest if it does not find an HttpServletRequest and will use the custom "AxisHttpRequestContext" implementation to extract the multipart parameters. I created a patch, but it was mean for Axis2 1.4.1 and it is not very appropriate for Axis2 1.5 since the http transport classes are moved to a separate module and the MultipartFormDataBuilder is not able to reference them anymore. As a workaround I provided a new MultipartFormDataBuilder in the http transport module, which extends the one in axis2 kernel. If running Axis2 standalone , users will need to specify that one in the axis2.xml, e.g.: <messageBuilders> ... <messageBuilder contentType="multipart/form-data" class="org.apache.axis2.transport.http.MultipartFormDataBuilder"/> </messageBuilders> Is should be possible to use some factory mechanism to avoid having two MultipartFormDataBuilder implementations. But this would require some design changes which I will leave to you.
          Hide
          detyo Detelin Yordanov added a comment -

          A sample Maven/Eclipse project with a JUnit test that demonstrates the problem.

          Show
          detyo Detelin Yordanov added a comment - A sample Maven/Eclipse project with a JUnit test that demonstrates the problem.
          Hide
          detyo Detelin Yordanov added a comment - - edited

          A sample web service that can be used to demonstrate the problem - deploy to a standalone Axis2 server and invoke it with multipart REST request.

          Show
          detyo Detelin Yordanov added a comment - - edited A sample web service that can be used to demonstrate the problem - deploy to a standalone Axis2 server and invoke it with multipart REST request.

            People

            • Assignee:
              Unassigned
              Reporter:
              detyo Detelin Yordanov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development