Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8059

@FormParam inside @BeanParam not working

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.18, 3.2.9, 3.3.2
    • Fix Version/s: 3.2.10, 3.3.3
    • Component/s: JAX-RS
    • Labels:
      None
    • Environment:
    • Estimated Complexity:
      Unknown

      Description

      class UserInsert {
      @FormParam("name") //not work
      private String name;
      @HeaderParam("Authorization") //work
      private String authorization;
      @PathParam("id") //work
      private String id;
      @QueryParam("login") //work
      private String login;

      public void setName(String name)

      { this.name = name; }

      public void setAuthorization(String authorization)

      { this.authorization = authorization; }

      public void setId(String id)

      { this.id = id; }

      public void setLogin(String login)

      { this.login = login; }

      }

      @Path("user")
      interface UserResource {

      @Path("

      {id}

      ")
      @POST
      @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
      @Produces(MediaType.WILDCARD)
      Response save(@BeanParam UserInsert userInsert);

      }

      public class Main {

      public static void main(String[] args) {

      WireMockServer wireMockServer = new WireMockServer(wireMockConfig().port(8080).notifier(new ConsoleNotifier(true)));
      wireMockServer.start();

      try

      { UserInsert userInsert = new UserInsert(); userInsert.setName("Victor Machado Pasqualino"); userInsert.setAuthorization("Basic YWRtaW46YWRtaW4="); userInsert.setId("5a4cfa7d-d3bd-4483-968f-b5826ec07712"); userInsert.setLogin("victorpasqualino"); JAXRSClientFactoryBean jaxrsClientFactory = new JAXRSClientFactoryBean(); jaxrsClientFactory.setAddress("http://localhost:8080/rest"); jaxrsClientFactory.setResourceClass(UserResource.class); jaxrsClientFactory.getOutInterceptors().add(new LoggingOutInterceptor()); UserResource userResource = jaxrsClientFactory.create(UserResource.class); userResource.save(userInsert); }

      finally

      { wireMockServer.stop(); }

      }

      }

      Client Request:
      INFO: Outbound Message
      ---------------------------
      ID: 1
      Address: http://localhost:8080/rest/user/5a4cfa7d-d3bd-4483-968f-b5826ec07712?login=victorpasqualino
      Http-Method: POST
      Content-Type: application/x-www-form-urlencoded
      Headers:

      {Authorization=[Basic YWRtaW46YWRtaW4=], Content-Type=[application/x-www-form-urlencoded], Accept=[application/xml]}

      --------------------------------------

      Server Request:
      2019-06-19 01:53:29.363 Request was not matched as there were no stubs registered:
      {
      "url" : "/rest/user/5a4cfa7d-d3bd-4483-968f-b5826ec07712?login=victorpasqualino",
      "absoluteUrl" : "http://localhost:8080/rest/user/5a4cfa7d-d3bd-4483-968f-b5826ec07712?login=victorpasqualino",
      "method" : "POST",
      "clientIp" : "127.0.0.1",
      "headers" :

      { "Authorization" : "Basic YWRtaW46YWRtaW4=", "Accept" : "application/xml", "Cache-Control" : "no-cache", "User-Agent" : "Apache-CXF/3.1.18", "Connection" : "keep-alive", "Host" : "localhost:8080", "Pragma" : "no-cache", "Content-Length" : "0", "Content-Type" : "application/x-www-form-urlencoded" }

      ,
      "cookies" : { },
      "browserProxyRequest" : false,
      "loggedDate" : 1560905608975,
      "bodyAsBase64" : "",
      "body" : "",
      "scheme" : "http",
      "host" : "localhost",
      "port" : 8080,
      "loggedDateString" : "2019-06-19T00:53:28Z",
      "queryParams" : {
      "login" :

      { "key" : "login", "values" : [ "victorpasqualino" ] }

      }
      }

      2019-06-19 01:53:29.368 Request received:
      127.0.0.1 - POST /rest/user/5a4cfa7d-d3bd-4483-968f-b5826ec07712?login=victorpasqualino

      Authorization: [Basic YWRtaW46YWRtaW4=]
      Accept: [application/xml]
      Cache-Control: [no-cache]
      User-Agent: [Apache-CXF/3.1.18]
      Connection: [keep-alive]
      Host: [localhost:8080]
      Pragma: [no-cache]
      Content-Length: [0]
      Content-Type: [application/x-www-form-urlencoded]

        Attachments

          Activity

            People

            • Assignee:
              reta Andriy Redko
              Reporter:
              victorpasqualino Victor Machado Pasqualino

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment