[英]No message body writer found for class : class java.util.HashMap
I am trying to consume a JAXRS endpoint. 我正在尝试使用JAXRS端点。 here is what I tried to make it work. 这是我试图使其起作用的方法。
Map<String, String> variables = new HashMap<String, String>();
variables.put("email", "sample@gmail.com");
List<Object> providers = new ArrayList<Object>();
JSONProvider provider = new JSONProvider();
provider.setNamespaceMap(variables);
providers.add(provider);
WebClient plainAddClient = WebClient.create("http://hostname:portnumber/cxf/jaxrs/EmailService/subscriber/update", providers);
plainAddClient.accept("application/json").type("application/json").post(variables);
when I try to run the above snippet, I get the following exception: 当我尝试运行上述代码段时,出现以下异常:
org.apache.cxf.jaxrs.client.AbstractClient.reportNoMessageHandler(AbstractClient.java:486) - .No message body writer found for class : class java.util.HashMap.
I have no clue whats going wrong with my approach. 我不知道我的方法出了什么问题。 Thanks for any suggestion. 感谢您的任何建议。
Seems to me like you're attempting to send json to the server but actually sending the HashMap instead? 在我看来,您正在尝试将json发送到服务器,但实际上是在发送HashMap吗? Is your message body correctly converted to json before sending it? 发送之前,您的消息正文是否正确转换为json?
Maybe try to send plain json for testing 也许尝试发送普通的json进行测试
plainAddClient.accept("application/json")
.type("application/json")
.post({"email":"sample@gmail.com"})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.