我使用Spring的web 3.1.1和春季OXM 3.1.1。UnmarshalException在Spring 3.1的RESTful服務使用XML請求
時jaxb2marshaller嘗試和解組XML源到對象 吹塑異常發生。
2012-12-03 13:38:41,152[k.c.s.s.c.r.AuthenticationController:154][ERROR] JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned
org.springframework.oxm.UnmarshallingFailureException: JAXB unmarshalling exception; nested exception is javax.xml.bind.UnmarshalException: Namespace URIs and local names to the unmarshaller needs to be interned
at org.springframework.oxm.jaxb.Jaxb2Marshaller.convertJaxbException(Jaxb2Marshaller.java:761) ~[org.springframework.oxm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:682) ~[org.springframework.oxm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.oxm.jaxb.Jaxb2Marshaller.unmarshal(Jaxb2Marshaller.java:665) ~[org.springframework.oxm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
我配置我喜歡這個sevlet設置JAXB2馬歇爾。
<oxm:jaxb2-marshaller id="marshaller">
<oxm:class-to-be-bound name="kr.co.skcomms.simon.bean.rest.Authentication" />
</oxm:jaxb2-marshaller>
並在控制器上嘗試像這樣解組。
@Autowired
public Jaxb2Marshaller marshaller;
....
Source source = new StreamSource(new StringReader(body));
Authentication authentication = (Authentication) marshaller.unmarshal(source);
與我的認證對象。
@XmlRootElement
public class Authentication {
private String simon_auth;
private String client_ip;
private String request_url;
public Authentication(){
}
@XmlElement
public String getSimon_auth() {
return simon_auth;
}
public void setSimon_auth(String simon_auth) {
this.simon_auth = simon_auth;
}
@XmlElement
public String getClient_ip() {
return client_ip;
}
public void setClient_ip(String client_ip) {
this.client_ip = client_ip;
}
@XmlElement
public String getRequest_url() {
return request_url;
}
public void setRequest_url(String request_url) {
this.request_url = request_url;
}
}
我refered這篇文章.. http://www.ibm.com/developerworks/webservices/library/wa-spring3webserv/index.html
我認爲我的消息來源是與本文的示例代碼是絕對相同的。
,但它不能很好地工作。
我感謝你的幫助。