1

I'm using Apache wink for my RESful services. I have two methods like below,

@POST
@Produces("multipart/mixed")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public BufferedOutMultiPart dummyMethod(@Context HttpServletRequest profileRegisterRequest){
}

@POST
@Produces("multipart/mixed")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public BufferedOutMultiPart dummyMethod(InMultiPart inMultiPart){
}

and the HTML form like this

<form action="someurl" method="post" enctype="multipart/form-data">
//   some elements
</form>

When I submit the form, the method with consumes multipart is executed. This is working as expected.

But when I change the form's enctype to "application/x-www-form-urlencoded" like below,

<form action="someurl" method="post" enctype="application/x-www-form-urlencoded">
    //   some elements
    </form>

the method which consumes multipart is executed. I'm not expecting this behaviour. I need the first method to be executed.

I'm going to remove the multipart content fromt he form and for backward compatibility I'm not going to remove the method which serves multipart.

Note: I need both the methods to be working because I might get multipart content inside the form. Leaving the form with enctype="multipart/form-data" works even when I don't have multipart content in the form. But I think its not the REST service standards.

Raja Asthana
  • 2,080
  • 2
  • 19
  • 35

0 Answers0