且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebResponse发布空字符串

更新时间:2023-02-25 22:59:38

来自@FormParam的Javadoc(重点是我的):

From the Javadoc of @FormParam (emphasis mine):

将请求实体主体中包含的表单参数的绑定到资源方法参数.

Binds the value(s) of a form parameter contained within a request entity body to a resource method parameter.

也就是说,如果您调用validate()方法,例如从cURL这样

That is, if you invoke your validate() method e.g. from cURL like this

curl -X POST --data-urlencode 'xml=<hml>...</hml>' http://localhost:8080/validate

然后方法参数xml将绑定到值<hml>...</hml>ValidateMiring服务将在该值上返回消息XML is null.(至少对我来说).

then the method parameter xml will be bound to the value <hml>...</hml> on which the ValidateMiring service returns a message XML is null. (at least to me).

相反,如果在方法参数前添加前缀xml=到实际的Web服务之前,应该得到不同的结果:

If you, instead, prepend your method parameter with a prefix xml= before you post it to the actual web service, you should get a different result:

ClientResponse response = webResource.accept("application/xml").post(ClientResponse.class, "xml=" + xml);