【发布时间】:2016-06-17 16:44:05
【问题描述】:
我开发了一项用于订单管理的 Web 服务。此 Web 服务将许多复杂对象作为输入参数。我使用 curl 进行测试,它工作正常。现在我正在编写一个客户端,但 在使用 ArrayList 时遇到问题(例如,这些项目以 ArrayList 的形式出现)对象。它作为字符串发送。这似乎是我使用的客户端框架的限制。我已经尝试过一两个开放框架,但它们没有按预期工作。如果您能通过一些示例提出一些框架,那就太好了。
以下是示例 curl 请求,为了简单起见,我删除了一些额外的参数。
curl -L -v -b agent_cookies.txt -H "Content-Type: application/json" -d "{"items":{"atg-rest-class-type":"java.util.ArrayList","atg-rest-values": [{"atg-rest-class-type":"com.bean.CommerceItemInfo","tinSkuNumber":"41589367","itemNumber": 280594,"颜色": 9,"尺寸": 94,"salePrice":50.00,"taxAmount":3.5,"stateTax":0.48,"countyTax":0.08,"currencyCode":"USD"},{"atg-rest-class-type":"com.. bean.CommerceItemInfo", "tinSkuNumber":"41589375","itemNumber": 280594,"color": 9,"size": 96,"salePrice":100.00,"taxAmount":7,"stateTax":0.96,"countyTax":0.16,"currencyCode":"USD"}]},orderInfo:{...},"clientAddress":{ “atg-rest-class-type”:“java.util.ArrayList”,“atg-rest-values”: [{"atg-rest-class-type":"com.bean.ClientAddress",\"firstName\":\"John\",\"lastName\":\"Dao\",\"state\": \"FL\",\"country\":\"US\",\"postalCode\":\"33606\",\"address1\":\"100 S Edison Avenue\",\"address2\":\"套房 D\",\"city\":\"Tampa\",\"addressType\":\"BOTH\"}]},{......}}" http://localhost:8080/rest/model/com/web/actor/CartActor/testOrder
谢谢
【问题讨论】:
-
如果您想将
"atg-rest-class-type":"java.util.ArrayList","atg-rest-values": [{"atg-rest-class-type":"com.bean.CommerceItemInfo"...反序列化为ArrayList<CommerceItemInfo>,您要么必须使用发明了这种可怕的序列化格式的奇怪的atg 框架,要么编写大量代码来执行此操作或使用不试图成为 java 序列化程序的适当的 restful 格式。 -
没错,这个 atg 框架很烂。我已经尝试过 atg 客户端,但它无法转换自定义 bean。你能举一个例子吗?
-
究竟是为了什么?使用 jax-rs 的自定义反序列化器?
-
No..example with atg frameowrk.
标签: java rest resteasy jersey-client