我想在客戶端解組JAXB,但我得到對象的屬性NULL。RestFul服務(spring3)CLIENT java?
那是我在做什麼來解組
URL url = new URL("http://localhost:9191/service/firstName/tony?format=xml");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/atom+xml");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
JAXBContext jaxbContext = JAXBContext.newInstance(LDAPUsers.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
LDAPUsers lu = (LDAPUsers) jaxbUnmarshaller.unmarshal(br);
ArrayList<LDAPUser> list = new ArrayList<LDAPUser>();
//list.addAll(lu.getCounty());
**System.out.println(lu.ldapUser.get(0).getFirstName());//this is giving NULL**
conn.disconnect();
請幫助!
調試和使用斷點到列表中,選中這個名單不是空和對象設置了所有屬性。 – jmventar
它不會觸發setter ... – user1534466
你的XML和域對象是什麼樣的? –