के लिए नहीं जाना जब मैं एक विशेष शोकहारा सेवा विधि कॉल, मैं निम्न त्रुटि, किसी को पता हो क्यों और कैसे इसे हल करने के लिए?JAXB अपवाद: कक्षा, जो <em>CXF</em> का उपयोग कर बनाया गया है इस संदर्भ
JAXBException हुआ: कक्षा com.octory.ws.dto।
public class Service { public Response results() { Collection<ProfileDto> profilesDto = new ArrayList<ProfileDto>(); ... SearchResultDto srd = new SearchResultDto(); srd.setResultEntities(profilesDto); // Setting profilesDto collection as resultEntities srd.setResultSize(resultSize); return Response.ok(srd).build(); } }
SearchResultDto:
ProfileDto और न ही अपनी सुपर वर्ग इस संदर्भ के लिए जाना जाता है के किसी भी ...@XmlRootElement(name="searchResult") public class SearchResultDto { private Collection resultEntities; private int resultSize; public SearchResultDto() { } @XmlElementWrapper(name="resultEntities") public Collection getResultEntities() { return resultEntities; } public void setResultEntities(Collection resultEntities) { this.resultEntities = resultEntities; } public int getResultSize() { return resultSize; } public void setResultSize(int resultSize) { this.resultSize = resultSize; } }
के बाद सेवा विधि और प्रासंगिक DTOs हैं
प्रोफ़ाइल:
@XmlRootElement(name="profile")
public class ProfileDto {
...
...
public ProfileDto() { }
...
}
@XmlSeeAlso जोड़ा जा रहा है इस मुद्दे को हल; मैं इस धारणा के तहत था कि एनोटेशन केवल तभी जरूरी था जब संदर्भित वर्ग एक उप-वर्ग था। धन्यवाद। – ABK07
क्या होगा यदि कक्षा 'SearchResultDto' है जहां टी सामान्य है? –
@ हेन्डी इरावॉन - एनोटेशन को वेब सेवा में भी जोड़ा जा सकता है (यानी '@ वेब सेवा' एनोटेशन के बाद)। यदि आप जेनेरिक से निपट रहे हैं तो अतिरिक्त स्तरों को घोषित करने के लिए और अधिक समझदारी होती है क्योंकि उस चरण तक आपको प्रकारों का पूरा सेट पता होना चाहिए। – CurtainDog