[英]jaxb unmarshalling returns null
I'm unmarshalling a response for soap message like the following 我正在解组肥皂消息的响应,如下所示
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<m:soResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:m="urn:tec">
<Error/>
<Order>
<Number>6</Number>
</Order>
</m:soResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
and i'm binding the jaxb annotation as 我正在将jaxb注释绑定为
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"body"
})
@XmlRootElement(name = "Envelope")
public class Envelope {
@XmlElement(name = "Body", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected Body body;
//......
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"soResponse"
})
@XmlRootElement(name = "Body")
public class Body {
@XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected soResponse;
//-----------
}
XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"error",
"order"
})
@XmlRootElement(name = "soResponse")
public class soResponse{
@XmlElement(name = "Error", required = true)
protected soResponse.Error error;
@XmlElement(name = "Order", required = true)
protected soResponse.Order order;
@XmlAttribute(name = "encodingStyle", namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
@XmlSchemaType(name = "anyURI")
protected String encodingStyle;
//-----------------------
}
the problem is, that i'm getting soResponse always null !!? 问题是,我得到soResponse永远是空的!!?
It looks like you've got the wrong namespace on your 看起来你的命名空间错了
@XmlElement(namespace = "http://schemas.xmlsoap.org/soap/envelope/", required = true)
protected soResponse;
This would look for a <SOAP-ENV:soResponse>
, not a <m:soResponse xmlns:m="urn:tec">
. 这将寻找
<SOAP-ENV:soResponse>
,而不是<m:soResponse xmlns:m="urn:tec">
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.