Jersey client exception: A message body writer was not found

前端 未结 6 1076
说谎
说谎 2020-12-03 15:55

I am using Jersey client to hit a PHP web service for image uploading functionality. I am getting the following exception:

Caused by: com.sun.jersey.api.clie         


        
6条回答
  •  庸人自扰
    2020-12-03 16:25

    Register the MultiPartWriter provider when creating the Client:

    ClientConfig cc = new DefaultClientConfig();
    Client client;
    
    cc.getClasses().add(MultiPartWriter.class);
    client = Client.create(cc);
    

    If using Maven, these are the dependencies you need in your pom.xml:

    
        com.sun.jersey
        jersey-client
        1.17.1
    
    
        com.sun.jersey.contribs
        jersey-multipart
        1.17.1
    
    

提交回复
热议问题