@RequestMapping(method=RequestMethod.POST, value="/employeeXML")
public ModelAndView addEmployeePostXMl(@RequestBody String body) {
Source source = new StreamSource(new StringReader(body));
Employee e = (Employee) jaxb2Mashaller.unmarshal(source);
employeeDS.add(e);
List<Employee> employees = employeeDS.getAll();
EmployeeList list = new EmployeeList(employees);
return new ModelAndView(XML_VIEW_NAME, "employees", list);
}
我可以測試它的單POST主體即通過JMETER測試Spring RESTful服務。如何爲XML數據提供多個動態輸入?
<employee>
<id>3</id>
<name>guest3</name>
<email>[email protected]</email>
</employee>.
但如何檢查它像CSV文件。如果多個動態值我使用CSV文件與數據:
3 aFFaFD xfchghcxh
4 dsfgsdF cxhchcxht
5 asFDdsF chcxhcg
6 sdFsF cxhxhcgh
7 SDFsF cghcxhcg
8 gfzsgzd cxghchc
9 hgfxhfx cghchgc
10 fghxf ghcxhxc
11 fhgfxh cghchcc
12 ghcxxh cxhcghch
13 chgxgcvx cghchcxgch
14 hgxfhxch cxhgxchcg
15 ghcxhcx vmcvmnvbm
16 cghch bnmvmbh
17 cxghcxhcx mvbhgn
18 cxghcxh mnmcghmh
19 cxghcxhxch mnvmvmcv
20 xcghchcx mvcmvmv
它給unmarshalling異常,因爲後主體應該是XML格式。
非常感謝@Alies Belik的工作。 – user1500694 2012-07-20 05:55:46